| rray_unstack | R Documentation |
rray_unstack() splits an array along axis and then removes that axis
from each of the resulting arrays. The result is a list of arrays that have
a dimensionality 1 less than x itself.
Using rray_stack() along the same axis reconstructs x.
rray_unstack(x, ..., axis)
x |
An array. |
... |
These dots are for future extensions and must be empty. |
axis |
The axis to unstack along, given by position or by title. |
Names along axis become the names of the returned list. Names on the
surviving axes are carried over to their new locations, as are their titles.
Because the dimensionality is reduced by 1, x must have a dimensionality
of at least 2 to begin with.
A list of arrays with the same dimensions as x, except that axis has
been removed.
rray_stack()
x <- array(1:6, c(2, 3))
# One array per row
rray_unstack(x, axis = 1)
# One array per column
rray_unstack(x, axis = 2)
# One array per column, by title
z <- rray_set_titles(x, c("row", "col"))
rray_unstack(z, axis = "col")
# Names along the axis become list names
y <- array(1:4, c(2, 2), dimnames = list(c("a", "b"), c("x", "y")))
rray_unstack(y, axis = 2)
# Unstacking and stacking along the same axis are inverses
rray_stack(!!!rray_unstack(x, axis = 2), .axis = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.