index_functions: Split into List

Description Usage Arguments Functions Examples

Description

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.)

Usage

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)

Arguments

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 were set to FALSE)

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

Functions

Examples

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)

bfatemi/easydata documentation built on Oct. 7, 2019, 4:35 p.m.