calc_chunks {utile.tools} | R Documentation |
Calculate data chunk indices
Description
Calculates chunk indices of a data object for a given chunk size (number of items per chunk).
Usage
calc_chunks(x, size = 10, reverse = FALSE)
Arguments
x |
A data frame or vector. |
size |
An integer. The number of items (e.g. rows in a tibble) that make up a given chunk. Must be a positive integer. Caps out at data maximum. |
reverse |
A logical. Calculate chunks from back to front. |
Value
An iterable list of row indices for each chunk of data.
Examples
# Create chunk map for a data frame
chunks <- calc_chunks(mtcars, size = 6)
# Iterate through chunks of data
for (chunk in chunks) print(paste0(rownames(mtcars[chunk,]), collapse = ', '))
[Package utile.tools version 0.3.0 Index]