Description Usage Arguments Value Note Examples
easysplit
is a function that efficiently splits a data.table,
vector, or matrix based on criteria given by the user into multiple datasets
within a list.
1 |
x |
A data.table, matrix, or vector to split into list elements |
ll |
A list of named vectors where the vector names correspond to named elements of x and such that the values dictate the groups to split "x" by. where the values The elements of "ll" could be vectors of length greater than or equal to 1. See examples below. |
A list with one or more elements that are of the same class as "x" but have been split on values in "ll"
The number of elements in "ll" and the size of those elements determines the number of elements in the return value.
1 2 3 4 5 6 7 8 9 10 | library(data.table)
dt <- data.table(ColA = c(1, 2, 3, 4, 5, 4, 4, 3, 3),
ColB = c("a", "b", "b", "c", "c", "c", "d", "e", "f"),
ColC = rnorm(9))
# Split the data by two values from ColA and one value from ColB.
# This will return a list of three data.tables
#
easysplit(x=dt, list(ColA = 3:4, ColB = "c"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.