Re: [R] Sums based on values of other matrix

2013-09-26 Thread arun
rsday, September 26, 2013 7:15 PM Subject: Re: [R] Sums based on values of other matrix Hi, If you have missing values:  set.seed(125)  A<- matrix(sample(c(NA,0:9),10*10,replace=TRUE),10,10)  set.seed(49)  B<- matrix(sample(c(NA,1:25),10*10,replace=TRUE),10,10) B1<- matrix(0,nrow=nrow(B),nco

Re: [R] Sums based on values of other matrix

2013-09-26 Thread arun
hlager Cc: R help Sent: Thursday, September 26, 2013 6:34 PM Subject: Re: [R] Sums based on values of other matrix Hi, Try: A<- structure(c(1, 2, 1, 2, 2, 1, 2, 1), .Dim = c(2L, 4L)) B<- structure(c(3, 1, 4, 1, 2, 2, 1, 2), .Dim = c(2L, 4L))  B1<- matrix(0,nrow(B),ncol(B)) B1[A==

Re: [R] Sums based on values of other matrix

2013-09-26 Thread arun
t.org" Cc: Sent: Thursday, September 26, 2013 5:51 PM Subject: [R] Sums based on values of other matrix Dear all, I have a big problem: - I got two matrices, A and B - A shows identifies the value of B, however the values of B must be summed - For instance, 1 1 2 2 2 2 1 1 gives matr

Re: [R] Sums based on values of other matrix

2013-09-26 Thread Sarah Goslee
Hi, You don't say what you want to do with the output, or whether you want to do it with more than one value, but here's one of the many possible ways to get your example: R> A <- matrix(c(1,1,2,2,2,2,1,1), nrow=2, byrow=TRUE) R> B <- matrix(c(3,4,2,1,1,1,2,2), nrow=2, byrow=TRUE) R> A [,1]

[R] Sums based on values of other matrix

2013-09-26 Thread tobias schlager
Dear all, I have a big problem: - I got two matrices, A and B - A shows identifies the value of B, however the values of B must be summed - For instance, 1 1 2 2 2 2 1 1 gives matrix a 3 4 2 1 1 1 2 2 gives matrix b Now the result for the value 1 would be 7 4 which are the rowsums o