Description Usage Arguments Details Value Examples
rray_expand()
inserts a new dimension at the axis
dimension. This
expands the number of dimensions of x
by 1
.
1 | rray_expand(x, axis)
|
x |
An rray. |
axis |
An integer of size |
Dimension names are kept through the insertion of the new dimension.
x
with a new dimension inserted at the axis
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | x <- rray(1:10, c(5, 2))
x <- rray_set_row_names(x, letters[1:5])
x <- rray_set_col_names(x, c("c1", "c2"))
# (5, 2)
# Add dimension to the front
# (1, 5, 2) = 1 row, 5 cols, 2 deep
rray_expand(x, 1)
# (5, 2)
# Add dimension to the middle
# (5, 1, 2) = 5 rows, 1 col, 2 deep
rray_expand(x, 2)
# (5, 2)
# Add dimension to the end
# (5, 2, 1) = 5 rows, 2 cols, 1 deep
rray_expand(x, 3)
# In some cases this is different than a simple
# rray_reshape() because the dimension names
# follow the original dimension position
# - 5 row names follow to the new 5 column position
# - 2 col names follow to the new 2 deep position
# - result has no row names because that is the new axis
rray_expand(x, 1)
# A reshape, on the other hand,
# drops all dimension names
rray_reshape(x, c(1, 5, 2))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.