Skip to content
Prev 168923 / 398506 Next

Odp: Matrix

Hi

r-help-bounces at r-project.org napsal dne 02.02.2009 16:52:06:
I would rbind both matrices and then indexed the resulting matrix.

x<-rep(10,4)
y<-rep(20,4)
dim(x)<-c(2,2)
dim(y)<-c(2,2)
z<-rbind(x,y)
[,1] [,2]
[1,]   10   10
[2,]   10   10
[3,]   20   20
[4,]   20   20

ind<-c(seq(1,4,2), seq(2,4,2))
z[ind,]
[,1] [,2]
[1,]   10   10
[2,]   20   20
[3,]   10   10
[4,]   20   20

Regards
Petr
http://www.nabble.com/Matrix-tp21792064p21792064.html
http://www.R-project.org/posting-guide.html