View source: R/miscellaneous_functions.R
make_chunks | R Documentation |
Create a list that contains chunks of indices (that reference tasks by position) of either
a specified number of chunks n_chunks
,
useful, e.g., if we have a fixed number of processing units, or
a specified number of tasks per chunk chunk_size
,
useful, e.g., if we have a (upper) fixed number of elements than can be
processed at a time.
The
make_chunks(nx, n_chunks, chunk_size = 1000L)
nx |
An integer value. Number of tasks. |
n_chunks |
An integer value or missing. The number of chunks. |
chunk_size |
An integer value or missing. The number of tasks per chunk. |
A list of integer vectors (chunks) that contain indices of
all nx
tasks; either, the number of chunks is <= n_chunks
,
or the number of tasks/indices per chunk is <= chunk_size
.
splitIndices
nx <- 16
## Create list of indices by number of chunks,
(ids <- make_chunks(nx, n_chunks = 3))
print(length(ids))
## Create list of indices by size per chunk,
(ids <- make_chunks(nx, chunk_size = 5))
print(lengths(ids))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.