Description Usage Arguments Details Value Examples
This family of functions allows you to get and set dimension names in various ways.
rray_dim_names() returns a list of the dimension names.
rray_axis_names() returns a character vector or NULL containing the
names corresponding to the axis dimension.
rray_row_names() and rray_col_names() are helpers for getting the
row and column names respectively.
Each of these four functions also has "set" variants: a functional form
(i.e. rray_set_row_names()), and an assignment
form (i.e. rray_row_names<-()).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | rray_dim_names(x)
rray_dim_names(x) <- value
rray_set_dim_names(x, dim_names)
rray_axis_names(x, axis)
rray_axis_names(x, axis) <- value
rray_set_axis_names(x, axis, names, meta = NULL)
rray_row_names(x)
rray_row_names(x) <- value
rray_set_row_names(x, names, meta = NULL)
rray_col_names(x)
rray_col_names(x) <- value
rray_set_col_names(x, names, meta = NULL)
|
x |
The object to extract the dimension names for. |
value |
For |
dim_names |
A list of either character vectors or |
axis |
A single integer. The axis to select dimension names for. |
names |
A character vector of new dimension names
for the |
meta |
A single character representing an optional "meta" name
assigned to the |
Unlike dimnames() which can return NULL, rray_dim_names() always returns a
list the same length as the dimensionality of x. If any dimensions do not
have names, NULL is returned for that element of the list. This
results in an object that's length always matches the dimensionality of x.
rray_dim_names() returns a list of dimension names. The other names
functions return character vectors, or NULL, corresponding to the
names of a particular axis.
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 | 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")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.