chunk_vector {mlr3misc} | R Documentation |
Chunk Vectors
Description
Chunk atomic vectors into parts of roughly equal size.
chunk()
takes a vector length n
and returns an integer with chunk numbers.
chunk_vector()
uses base::split()
and chunk()
to split an atomic vector into chunks.
Usage
chunk_vector(x, n_chunks = NULL, chunk_size = NULL, shuffle = TRUE)
chunk(n, n_chunks = NULL, chunk_size = NULL, shuffle = TRUE)
Arguments
x |
( |
n_chunks |
( |
chunk_size |
( |
shuffle |
( |
n |
( |
Value
chunk()
returns a integer()
of chunk indices,
chunk_vector()
a list()
of integer
vectors.
Examples
x = 1:11
ch = chunk(length(x), n_chunks = 2)
table(ch)
split(x, ch)
chunk_vector(x, n_chunks = 2)
chunk_vector(x, n_chunks = 3, shuffle = TRUE)
[Package mlr3misc version 0.15.1 Index]