[英]How can I create a 2D heatmap grid in R?
I have a data set like this 我有这样的数据集
head(data)
V1 V2
[1,] NA NA
[2,] NA NA
[3,] NA NA
[4,] 5 2
[5,] 5 2
[6,] 5 2
where 哪里
unique(data$V1)
[1] NA 5 4 3 2 1 0 6 7 9 8
unique(data$V2)
[1] NA 2 6 1 5 3 7 4 0 8 9
What I would like to do is a plot similar to this 我想做的是一个与此类似的情节
plot(df$V1,df$V2)
but with a colour indicator indicating how many match there are with a grid instead of points. 但带有一个颜色指示器,用于指示有多少个匹配项是使用网格而不是点。
Can anyone help me? 谁能帮我?
It looks like this may be what you want - first you tabulate using table()
, then plot a heatmap of the table using heatmap()
: 看起来这可能就是您想要的-首先使用
table()
制表,然后使用heatmap()
绘制表的heatmap()
:
set.seed(1)
data <- data.frame(V1=sample(1:10,100,replace=TRUE),V2=sample(1:10,100,replace=TRUE))
foo <- table(data)
heatmap(foo,Rowv=NA,Colv=NA)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.