Description Usage Arguments Details Value Examples
Obtain a list of common dimension names among a set of objects. For
interactive use, rray_dim_names_common()
is more useful.
1 2 3 |
x, y, ... |
Objects to find common dimensions for. |
rray_dim_names_common()
is the engine that determines what dim names should
be used in the result of arithmetic operations and other functions that
involve multiple rray objects and return a single result.
The rules for determining the set of common dim names between objects
x
and y
(in that order) are:
Compute the common dim
between x
and y
using rray_dim_common()
.
For each axis along the common dim
:
If x
has names for that axis and the size of the names vector
is the same as the size of the axis, use those names for that axis.
Else if y
has names for that axis and the size of the names vector
is the same as the size of the axis, use those names for that axis.
Otherwise, the names for that axis is NULL
.
A list of the common dimension names of the inputs.
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 31 32 33 34 | 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.