Question

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)

enter image description here

but with a colour indicator indicating how many match there are with a grid instead of points.

Can anyone help me?

Was it helpful?

Solution

It looks like this may be what you want - first you tabulate using table(), then plot a heatmap of the 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)

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top