View source: R/misc.utilities.R
split.array | R Documentation |
split()
method for array
and matrix
types on a margin.These methods split an array
and matrix
into a list of
arrays or matrices with the same number of dimensions
according to the specified margin.
## S3 method for class 'array'
split(x, f, drop = FALSE, margin = NULL, ...)
## S3 method for class 'matrix'
split(x, f, drop = FALSE, margin = NULL, ...)
x |
A |
f , drop |
See help for |
margin |
Which margin of the array to split along. |
... |
Additional arguments to |
x <- diag(5)
f <- rep(1:2, c(2,3))
split(x, f, margin=1) # Split rows.
split(x, f, margin=2) # Split columns.
# This is similar to how data frames are split:
stopifnot(identical(split(x, f, margin=1),
lapply(lapply(split(as.data.frame(x), f), as.matrix), unname)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.