HI,
You could also do this:
?lapply(sample1,function(x) {mat1<-cbind(matrix(0,nrow=2,ncol=3),x); mat1[cbind(rep(1,3),1:3)]<- mat1[cbind(rep(1,3),4:6)]; mat1[cbind(rep(1,3),4:6)]<-0; mat1})
A.K.
----- Original Message -----
From: Kathryn Lord <kathryn.lord2000 at gmail.com>
To: r-help at r-project.org
Cc:
Sent: Wednesday, January 16, 2013 2:59 AM
Subject: [R] matrix manipulation with its rows
Dear R users,
I have a question about matrix manipulation with its rows.
Plz see the simple example below
sample <- list(matrix(1:6, nr=2,nc=3), matrix(7:12, nr=2,nc=3),
matrix(13:18,nr=2,nc=3))