chunk {BBmisc} | R Documentation |
Chunk elements of vectors into blocks of nearly equal size.
Description
In case of shuffling and vectors that cannot be chunked evenly, it is chosen randomly which levels / chunks will receive 1 element less. If you do not shuffle, always the last chunks will receive 1 element less.
Usage
chunk(x, chunk.size, n.chunks, props, shuffle = FALSE)
Arguments
x |
[ANY] |
chunk.size |
[ |
n.chunks |
[ |
props |
[ |
shuffle |
[ |
Value
[unnamed list
] of chunks.
Examples
xs = 1:10
chunk(xs, chunk.size = 3)
chunk(xs, n.chunks = 2)
chunk(xs, n.chunks = 2, shuffle = TRUE)
chunk(xs, props = c(7, 3))