Description Usage Arguments Functions Examples
Functions to work with indices, or split objects by indices. Functionality includes: - Split into list element chunks using a given index that identifies the split points - Create a split index for distributed analysis (parallelization, etc.)
1 2 3 4 5 6 | split_by_index(dat = NULL, index = NULL, include_first = TRUE,
include_at_index = TRUE)
make_index(totalN = NULL, eachN, mat = FALSE)
splitn(vec, n)
|
dat |
A matrix, data.frame, data.table, or vector. If table form, split will occur at rows |
index |
A numeric vector that identifies the positions for which to split at |
include_first |
A logical indicating whether it is required to keep elements leading up to the first
index. For example, if I want to split a vector at position 5, 10, and 15, the default value of TRUE would ensure
elements 1 to 5 are returned (or 1 to 4 if argument |
include_at_index |
A logical indicating whether to include the element at the index, or drop it. The default value of TRUE will keep the element in result |
totalN |
A numeric value representing the total observations to split an index over |
eachN |
A numeric value representing the desired number of splits |
mat |
A boolean indicating whether to return the splits as a list or matrix (simplified) |
vec |
A vector to split into n list elements |
n |
The number of desired list elements to split vec into |
split_by_index
: Split a vector or table by a position given by index vector
make_index
: Create a split index for distributed analysis (parallelization, etc.)
splitn
: A convenience wrapper around splitIndices. Reduces a step potentially
1 2 3 4 5 | totalN <- 1000
eachN <- 10
make_index(totalN, eachN) # Not simplified
make_index(totalN, eachN, mat = TRUE) # simplified
splitn(letters, 4)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.