[R] Splitting a vector

Long Vo long_vo_hai at yahoo.com.vn
Tue Dec 10 05:19:53 CET 2013


Hi, I am quite new to R so I know that this probably is very basic , but how
can I split a sequence of number into multiple parts with equal length?
For example I have a vector

X=c(1:12)
I simply need to split it into sub-vectors with the same length N . Say N=3
then I need the output to be like 
1 2 3
4 5 6
7 8 9
10 11 12

And better if the sub-vectors can be named so that I can use them later for
individual study, probably a do-loop in which a function can be applied to
them.
I just want them to be in consecutive order so really no fancy conditions
here.  

Any helps to this amateur is greatly appreciated,
Long



--
View this message in context: http://r.789695.n4.nabble.com/Splitting-a-vector-tp4681930.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list