[R] Partition a vector into select groups with fixed length

Christofer Bogaso bog@@o@chr|@to|er @end|ng |rom gm@||@com
Sun Aug 18 20:01:35 CEST 2019


Let say I have a vector as below


Now I want to break this vector into groups of the same length of 5.

1st group consists - "A" "B" "C" "D" "E"
2nd group - "F" "G" "H" "I" "J"

and so on..
last group will consist only the leftover elements

I have a very large initial vector, so looking for some efficient way
to achieve the same. Any pointer will be highly appreciated.

Thanks for your time.

More information about the R-help mailing list