How can I create a 2D heatmap grid in R? -
i have data set 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 plot similar this
plot(df$v1,df$v2)
but colour indicator indicating how many match there grid instead of points.
can me?
it looks may want - first tabulate using table()
, plot heatmap of table using 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)
Comments
Post a Comment