common-dim-names: Find common dimension names

Description Usage Arguments Details Value Examples

Description

Obtain a list of common dimension names among a set of objects. For interactive use, rray_dim_names_common() is more useful.

Usage

1
2
3

Arguments

x, y, ...

Objects to find common dimensions for.

Details

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:

Value

A list of the common dimension names of the inputs.

Examples

 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)

DavisVaughan/rray documentation built on Feb. 5, 2020, 10:06 p.m.