powered by
Calculates chunk indices of a data object for a given chunk size (number of items per chunk).
calc_chunks(x, size = 10, reverse = FALSE)
An iterable list of row indices for each chunk of data.
A data frame or vector.
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.
A logical. Calculate chunks from back to front.
# 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 = ', '))
Run the code above in your browser using DataLab