Learn R Programming

Xmisc (version 0.0.9)

vchunk: Chunk a vector into parts

Description

Chunk a vector into parts given the number of chunks or the max size of a chunk

Usage

vchunk(x, n = NULL, max.size = NULL, aeap = TRUE)

Arguments

x
vector to chunk
n
numeric, the number of chunks
max.size
numeric, the maximal size of a chunk
aeap
logical, as equal as possible. Whether return balanced chunks.

Value

  • list

Examples

Run this code
vchunk(1:7,7)
vchunk(1:19,n=3)
vchunk(1:19,max.size=9)
vchunk(1:19,max.size=9,aeap=FALSE) # unbalanced chunks

Run the code above in your browser using DataLab