Description Usage Arguments Value Note See Also Examples
Split data forms at specified integer indices.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | split_index(
x,
indices = if (is.atomic(x)) { NULL } else { change_index(x) },
names = NULL,
...
)
## S3 method for class 'list'
split_index(x, indices, names = NULL, ...)
## S3 method for class 'data.frame'
split_index(x, indices, names = NULL, ...)
## S3 method for class 'matrix'
split_index(x, indices, names = NULL, ...)
## S3 method for class 'numeric'
split_index(x, indices = change_index(x), names = NULL, ...)
## S3 method for class 'factor'
split_index(x, indices = change_index(x), names = NULL, ...)
## S3 method for class 'character'
split_index(x, indices = change_index(x), names = NULL, ...)
## Default S3 method:
split_index(x, indices = change_index(x), names = NULL, ...)
|
x |
A data form ( |
indices |
A vector of integer indices to split at. If |
names |
Optional vector of names to give to the list elements. |
... |
Ignored. |
Returns of list of data forms broken at the indices
.
Two dimensional object will retain dimension (i.e., drop = FALSE
is used).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ## character
split_index(LETTERS, c(4, 10, 16))
split_index(LETTERS, c(4, 10, 16), c("dog", "cat", "chicken", "rabbit"))
## numeric
split_index(1:100, c(33, 66))
## factor
(p_chng <- change_index(CO2[["Plant"]]))
split_index(CO2[["Plant"]], p_chng)
#`change_index` was unnecessary as it is the default of atomic vectors
split_index(CO2[["Plant"]])
## list
split_index(as.list(LETTERS), c(4, 10, 16))
## data.frame
(vs_change <- change_index(mtcars[["vs"]]))
split_index(mtcars, vs_change)
## matrix
(mat <- matrix(1:50, nrow=10))
split_index(mat, c(3, 6, 10))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.