make_list_at_index: Split a vector into a list based on indices

Description Usage Arguments Value Examples

Description

This function takes a vector and indices from that vector and splits the vector into a list at the assigned indices. Values at the indices can either be kept or discarded.

Usage

1
make_list_at_index(vec, ind, keep_indices = TRUE)

Arguments

vec

A vector of any length or class

ind

Numeric vector depicting the indices at which to split the list

keep_indices

Logical. Return the indices in each element of the list or not

Value

A list with length equal to that of the lenght of vec. Each element contains the values in between the indices including the values at the indices if keep_indices = TRUE, the default.

Examples

1
2
3
a <- letters
ind <- grep("a|e|i|o|u", a)
consonants <- make_list_at_index(a, ind, keep_indices = FALSE)

inspktrgadget/gadgetSim documentation built on May 10, 2019, 9:51 a.m.