| rray_stack | R Documentation |
rray_stack() joins arrays along a new axis inserted at .axis. All
preexisting axes are broadcast to their common dimension.
The new axis has a dimension equal to the number of arrays you are stacking.
rray_stack(..., .axis)
... |
Arrays to stack. |
.axis |
The axis to stack along, given by position in the output. Must be between 1 and one greater than the maximum dimensionality of the input arrays. For example, you can stack 2D matrices along axis 3, but not axis 4. |
This function participates in rray's
common name determination rules on every existing axis.
Names of ... become the names of the new axis.
An array with the following dimensions:
Along .axis, the number of inputs.
Along all other axes, the common dimensions of the inputs taken via broadcasting.
rray_unstack(), rray_combine()
x <- array(1:12, c(3, 4))
y <- array(13:24, c(3, 4))
# (3, 4) -> (2, 3, 4)
rray_dimensions(rray_stack(x, y, .axis = 1))
# (3, 4) -> (3, 4, 2)
rray_stack(x, y, .axis = 3)
# Existing axes are broadcast
# (3, 1) and (3, 4) -> (2, 3, 4)
a <- array(1:3, c(3, 1))
b <- array(1:12, c(3, 4))
rray_dimensions(rray_stack(a, b, .axis = 1))
# Names of `...` name the new axis
rray_stack(first = 1:2, second = 3:4, .axis = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.