[R] Splitting matrix into several small matrices

kathie kathryn.lord2000 at gmail.com
Tue Jul 28 00:46:30 CEST 2009


Dear R users...

I need to split this matrix(or dataframe), for example,

z <- matrix(c(13,1,1,1,1,12,0,0,0,0,8,1,0,1,1,8,0,1,0,0,
                  10,1,1,1,1,3,0,1,0,0,3,1,0,1,1,6,1,1,1,1),8,5,byrow = T)


> z
     [,1] [,2] [,3] [,4] [,5]
[1,]   13    1    1    1    1
[2,]   12    0    0    0    0
[3,]    8    1    0    1    1
[4,]    9    0    1    0    0
[5,]   10    1    1    1    1
[6,]    3    0    1    0    0
[7,]    3    1    0    1    1
[8,]    6    1    1    1    1


(actually, z matrix is big, about 1000*15 matrix)

to 4 matrices like this way,


#- 1st matrix--------------------------------------
13    1    1    1    1
10    1    1    1    1
 6    1    1    1    1

#- 2nd matrix--------------------------------------
12    0    0    0    0


#- 3rd matrix--------------------------------------
8    1    0    1    1
3    1    0    1    1


#- 4th matrix--------------------------------------
9    0    1    0    0
3    0    1    0    0



Any comments will be greatly appreciated.

Kathryn Lord
-- 
View this message in context: http://www.nabble.com/Splitting-matrix-into-several-small-matrices-tp24689585p24689585.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list