Learn R Programming

statnet.common (version 4.13.0)

split_len: Split a list or some other split()-able object by lengths

Description

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

Usage

split_len(x, l)

Value

A list with elements of the same type as x.

Arguments

x

an object with a split() method.

l

a vector of lengths of the subsets.

Examples

Run this code
x <- 1:10
l <- 1:4

o <- split_len(x, l)

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

Run the code above in your browser using DataLab