Skip to contents

IEA data can be "specified" by adding additional information. Three notations are useful: arrow, bracket, and from. Arrow notation is from -> to, and bracket notation is destination [source]. These functions change matrix row/column names among the notations.

  • arrow_to_from_byname() switches from arrow notation to from notation.

  • from_to_arrow_byname() switches from from notation to arrow notation.

  • arrow_to_bracket_byname() switches from arrow notation to bracket notation.

  • bracket_to_arrow_byname() switches from bracket notation to arrow notation.

Functions with the _byname suffix behave like functions in the matsbyname package. Specifically, they can work with a single matrix or a list of matrices supplied to the m argument.

Usage

arrow_to_from_byname(m, margin = c(1, 2))

from_to_arrow_byname(m, margin = c(1, 2))

arrow_to_bracket_byname(m, margin = c(1, 2))

bracket_to_arrow_byname(m, margin = c(1, 2))

Arguments

m

a single matrix or a list of matrices.

margin

the margin over which the notation switch should be made: 1 for rows, 2 for columns, or c(1, 2) (the default) for both rows and columns

Value

An object of same length as m with switched notation.

Examples

m <- matrix(c(1, 2,  
              3, 4), nrow = 2, ncol = 2, byrow = TRUE, 
            dimnames = list(c("a -> b", "c -> d"), c("f [e]", "h [g]")))
m
#>        f [e] h [g]
#> a -> b     1     2
#> c -> d     3     4
arrow_to_from_byname(m)
#>            f [e] h [g]
#> b [from a]     1     2
#> d [from c]     3     4
arrow_to_from_byname(m, margin = 2) # No changes expected.
#>        f [e] h [g]
#> a -> b     1     2
#> c -> d     3     4
from_to_arrow_byname(m)
#>        f [e] h [g]
#> a -> b     1     2
#> c -> d     3     4
arrow_to_bracket_byname(m)
#>       f [e] h [g]
#> b [a]     1     2
#> d [c]     3     4
bracket_to_arrow_byname(m)
#>        e -> f g -> h
#> a -> b      1      2
#> c -> d      3      4