array_flatten | R Documentation |
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
array_flatten(x, i)
x |
An array |
i |
An integer vector of dimensions to flatten |
A new array with at one or more dimensions removed
array_flatten which adds structure
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.