easy_split {csutil}R Documentation

Split a vector into a list of vectors

Description

Easily split a list into a list of equally sized vectors.

Usage

easy_split(x, size_of_each_group = NULL, number_of_groups = NULL)

Arguments

x

The vector to be split

size_of_each_group

If you want to split 'x' into a number of groups, each of 'size_of_each_group' size

number_of_groups

How many equally sized groups do you want?

Details

You can either specify the length of the list (via 'number_of_groups') or the length of the equally sized vectors within each list element (via 'size_of_each_group'). The last element of the list can be shorter than the other elements.

Value

A list containing equally sized vectors.

Examples

easy_split(letters[1:20], size_of_each_group = 3)
easy_split(letters[1:20], number_of_groups = 3)

[Package csutil version 2023.4.25 Index]