switch_notation_byname {matsbyname} | R Documentation |
Change row and column name notation
Description
This function switches matrix row and/or column names from one type of notation to another
based on the from
and to
arguments.
Optionally, prefix and suffix can be flip
ped.
Usage
switch_notation_byname(a, margin = c(1, 2), from, to, flip = FALSE)
Arguments
a |
A matrix or list of matrices whose row and/or column notation is to be changed. |
margin |
|
from |
The |
to |
The |
flip |
A boolean that tells whether to also flip the notation. Default is |
Value
Matrices with row and column names with switched notation, per arguments.
Examples
m <- matrix(c(1, 2,
3, 4), nrow = 2, ncol = 2, byrow = TRUE,
dimnames = list(c("b [a]", "d [c]"), c("f [e]", "h [g]"))) %>%
setrowtype("Products [Industries]") %>% setcoltype("Industries [Products]")
m
switch_notation_byname(m, from = RCLabels::bracket_notation, to = RCLabels::arrow_notation,
flip = TRUE)
# Also works for lists.
# Note that margin must be specified as a list here.
switch_notation_byname(list(m, m), margin = list(c(1, 2)),
from = RCLabels::bracket_notation,
to = RCLabels::arrow_notation, flip = TRUE)
[Package matsbyname version 0.6.10 Index]