Splitting vector based on vector of chunk-lengths
问题 I've got a vector of binary numbers. I know the consecutive length of each group of objects; how can I split based on that information (without for loop)? x = c("1","0","1","0","0","0","0","0","1") .length = c(group1 = 2,group2=4, group3=3) x is the binary number vector that I need to split. .length is the information that I am given. .length essentially tells me that the first group has 2 elements and they are the first two elements 1,0 . The second group has 4 elements and contain the 4