array_flatten: Flatten array dimensions

View source: R/arrays.R

array_flattenR Documentation

Flatten array dimensions

Description

Flatten array dimensions into a single dimension. This takes a multidimensional array and converts some dimensions of it into a vector. Use this to drop out "middle" dimensions of a structured array. This is conceptually the inverse of array_reshape

Usage

array_flatten(x, i)

Arguments

x

An array

i

An integer vector of dimensions to flatten

Value

A new array with at one or more dimensions removed

See Also

array_flatten which adds structure

Examples

x <- array(1:12, c(2, 3, 4))
mcstate::array_flatten(x, 2:3)

# array_flatten and array_reshape are each others' conceptual
# opposites:
y <- mcstate::array_flatten(x, 2:3)
identical(mcstate::array_reshape(y, 2, c(3, 4)), x)

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