array_bind: Bind arrays

View source: R/arrays.R

array_bindR Documentation

Bind arrays

Description

Bind a number of arrays, usually by their last dimension. This is useful for binding together the sorts of arrays produced by dust and mcstate's simulation functions.

Usage

array_bind(..., arrays = list(...), dimension = NULL)

Arguments

...

Any number of arrays. All dimensions must the the same, except for the dimension being bound on which may vary.

arrays

As an alternative to using ... you can provide a list directly. This is often nicer to program with.

dimension

The dimension to bind on; by default NULL means the last dimension.

Value

A single array object

Examples

# Consider two matricies; this is equivalent to rbind and is
# pretty trivial
m1 <- matrix(1, 4, 5)
m2 <- matrix(2, 4, 2)
mcstate::array_bind(m1, m2)

# For a 4d array though it's less obvious
a1 <- array(1, c(2, 3, 4, 5))
a2 <- array(2, c(2, 3, 4, 1))
a3 <- array(3, c(2, 3, 4, 3))
dim(mcstate::array_bind(a1, a2, a3))

mrc-ide/mcstate documentation built on July 3, 2024, 1:34 p.m.