# NOT RUN {
library(magrittr)
# 1x2 - Row names but no column names
x <- rray(1, dim = c(1, 2)) %>%
rray_set_row_names("r_from_x")
# 1x1 - Row names and column names
y <- rray(1, dim = c(1, 1)) %>%
rray_set_col_names("c_from_y") %>%
rray_set_row_names("r_from_y")
# 1x1 - Row names but no column names
z <- rray(1, c(1, 1)) %>%
rray_set_row_names("r_from_z")
# Combining y and z
# y has names for both dimensions
# so they are used
rray_dim_names_common(y, z)
# Combining z and y
# - Row names are found first from z
# - But z has no column names
# - So column names are found from y
rray_dim_names_common(z, y)
# Combining x and y
# - Row names are found first from x
# - x has no column names
# - y has column names but they are
# a different length from the common
# column dimension (common size of 2)
# - So no column names are used
rray_dim_names_common(x, y)
# }
Run the code above in your browser using DataLab