Skip to contents

split_len() splits an object, such as a list or a data frame, into subsets with specified lengths.

Usage

split_len(x, l)

Arguments

x

an object with a split() method.

l

a vector of lengths of the subsets.

Value

A list with elements of the same type as x.

Examples

x <- 1:10
l <- 1:4

o <- split_len(x, l)

stopifnot(identical(lengths(o), l))
stopifnot(identical(unlist(o), x))