powered by
Split a vector to subvectors of specified lengths.
vpartition(x, lengths, matrixify = TRUE)
List of numeric vectors, or a matrix if all lengths are equal.
vector to be splitted.
numeric vector. Lengths of the subvectors.
logical. Whether to return matrix if lengths are identical.
Tomas Bacigal
If sum(lengths)>length(x) holds true, the extra places are filled with NAs.
sum(lengths)>length(x)
NA
vpartition(1:10,c(4,5,2))
Run the code above in your browser using DataLab