Hi,
Try:
split(X,as.numeric(gl(length(X),3,length(X))))
A.K.

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
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to