A split() method for array and matrix types on a 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 |
|
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)))Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.