1
votes

So, I have two matrices, let's say:

set.seed(11)
a<-matrix(rnorm(10000),ncol=100)
colnames(a)<-(c(1:100))
set.seed(31)
b<-matrix(rnorm(10000),ncol=100)
colnames(b)<-colnames(a)

I want to create a scatter plot where each point will have in:

x axis -> the value of (i,j) from matrix a

y axis -> the value for the same pair (i,j) from matrix b

Somewhat is more difficult for me than it seems..

1
Try plot(x=c(a),y=c(b))Robert
Is there a difference from the plot(as.vector(a), as.vector(b)) ? Because I get a slightly different plot.Kwnwps
There shouldn't really: This matrices seem to be the same: > identical(c(matrix(letters, nrow=2)), as.vector(matrix(letters, nrow=2))) [1] TRUELyzandeR
Yes, you are right, they are the same. Thanks.Kwnwps

1 Answers

5
votes

Converting them to vectors will do what you need. Every combination i,j from a will match the same combination of i,j from b:

plot(as.vector(a), as.vector(b))

enter image description here