Learn R Programming

acopula (version 0.9.4)

vpartition: Vector partitioning

Description

Split a vector to subvectors of specified lengths.

Usage

vpartition(x, lengths, matrixify = TRUE)

Value

List of numeric vectors, or a matrix if all lengths are equal.

Arguments

x

vector to be splitted.

lengths

numeric vector. Lengths of the subvectors.

matrixify

logical. Whether to return matrix if lengths are identical.

Author

Tomas Bacigal

Details

If sum(lengths)>length(x) holds true, the extra places are filled with NAs.

Examples

Run this code
vpartition(1:10,c(4,5,2))

Run the code above in your browser using DataLab