powered by
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.
chunk()
n
chunk_vector()
base::split()
chunk_vector(x, n_chunks = NULL, chunk_size = NULL, shuffle = TRUE)chunk(n, n_chunks = NULL, chunk_size = NULL, shuffle = TRUE)
chunk(n, n_chunks = NULL, chunk_size = NULL, shuffle = TRUE)
chunk() returns a integer() of chunk indices, chunk_vector() a list() of integer vectors.
integer()
list()
integer
(vector()) Vector to split into chunks.
vector()
(integer(1)) Requested number of chunks. Mutually exclusive with chunk_size and props.
integer(1)
chunk_size
props
(integer(1)) Requested number of elements in each chunk. Mutually exclusive with n_chunks and props.
n_chunks
(logical(1)) If TRUE, permutes the order of x before chunking.
logical(1)
TRUE
x
(integer(1)) Length of vector to split.
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)
Run the code above in your browser using DataLab