# NOT RUN {
library(magrittr)
x <- rray(1:10, c(5, 2))
rray_flatten(x)
# Dimension names are kept here
# (2) -> (2)
y <- rray(1:2) %>% rray_set_axis_names(1, letters[1:2])
rray_flatten(y)
# And they are kept here
# (2, 1) -> (2)
y_one_col <- rray_reshape(y, c(2, 1))
rray_flatten(y_one_col)
# But not here, since the size of the first dim changes
# (1, 2) -> (2)
y_one_row <- t(y_one_col)
rray_flatten(y_one_row)
# }
Run the code above in your browser using DataLab