# NOT RUN {
x <- rray(1:10, c(5, 2))
rray_dim_names(x) <- list(letters[1:5], NULL)
x
rray_dim_names(x)
# 3D object, so 3 dim name elements
rray_dim_names(rray(1, dim = c(1, 1, 1)))
# Vectors are treated as 1D arrays
vec <- c(x = 1, y = 2)
rray_dim_names(vec)
# You can add dim names more easily
# using rray_set_axis_names()
# and the pipe operator
library(magrittr)
y <- rray(1, c(1, 2, 1)) %>%
rray_set_axis_names(1, "r1") %>%
rray_set_axis_names(2, c("c1", "c2")) %>%
rray_set_axis_names(3, "3rd dim")
y
# You can set also set axis names to `NULL` to reset them
rray_set_axis_names(y, 2, NULL)
# You can set the "meta" names of an axis as well
rray_set_axis_names(y, 1, "r1", "row names")
# }
Run the code above in your browser using DataLab