Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

split.array

A split() method for array and matrix types on a margin.


Description

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.

Usage

## S3 method for class 'array'
split(x, f, drop = FALSE, margin = NULL, ...)

## S3 method for class 'matrix'
split(x, f, drop = FALSE, margin = NULL, ...)

Arguments

x

A matrix or an array.

f, drop

See help for split(). Note that drop here is not for array dimensions: these are always preserved.

margin

Which margin of the array to split along. NULL splits as split.default, dropping dimensions.

...

Additional arguments to split().

Examples

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

statnet.common

Common R Scripts and Utilities Used by the Statnet Project Software

v4.4.1
GPL-3 + file LICENSE
Authors
Pavel N. Krivitsky [aut, cre] (<https://orcid.org/0000-0002-9101-3362>), Skye Bender-deMoll [ctb]
Initial release
2020-10-03

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.