Learn R Programming

oeli (version 0.7.1)

split_vector_at: Split a vector at positions

Description

This function splits a vector at specific positions.

Usage

split_vector_at(x, at)

Value

A list.

Arguments

x

[atomic()`]
A vector of elements.

at

[integer()]
Index position(s) just before to split.

For example, at = n splits before the nth element of x.

References

Based on https://stackoverflow.com/a/19274414.

See Also

Other vector helpers: check_numeric_vector(), check_probability_vector(), chunk_vector(), insert_vector_entry(), map_indices(), match_numerics(), permutations(), subsets(), vector_occurrence()

Examples

Run this code
x <- 1:10
split_vector_at(x, c(2, 3, 5, 7))

Run the code above in your browser using DataLab