split_vector: Split a vector into chunks of size k.

Description Usage Arguments Details Value Examples

Description

This functions splits a vector into chunks of size k, and returns a list of vectors. The last vector in the list will be less than length k if k doesn't divide the length of the vector exactly.

Usage

1
split_vector(vec, k)

Arguments

vec

The vector to split into chunks.

k

The size of each chunks.

Details

Parameter k must be of type numeric. If not an integer, it will be coerced to an integer using trunc().

Parameter vec must be a vector but can contain any element type.

Value

A list of vectors, each vector of size k, except possibly the last one.

Examples

1
split_vector(c(1,2,3,4,5), 3)

jeanmarcgp/xtsanalytics documentation built on May 19, 2019, 12:38 a.m.