calc_chunks | R Documentation |
Calculates chunk indices of a data object for a given chunk size (number of items per chunk).
calc_chunks(x, size = 10, reverse = FALSE)
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. |
An iterable list of row indices for each chunk of data.
# 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 = ', '))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.