chunk_vector {oeli}R Documentation

Split a vector into chunks

Description

This function either

Usage

chunk_vector(x, n, type = 1, strict = FALSE)

Arguments

x

A vector.

n

An integer smaller or equal length(x).

type

Either 1 (default) to split x into n chunks of equal size or 2 to split x into chunks of size n.

strict

Set to TRUE to fail if length(x) is not a multiple of n, or FALSE (default), else.

Value

A list.

Examples

x <- 1:12
chunk_vector(x, n = 3, type = 1)
chunk_vector(x, n = 3, type = 2)
try(chunk_vector(x, n = 5, strict = TRUE))

[Package oeli version 0.5.2 Index]