matricize_byname: Matricize a vector

View source: R/Unary.R

matricize_bynameR Documentation

Matricize a vector

Description

Converts a vector with rows or columns named according to notation into a matrix.

Usage

matricize_byname(a, notation)

Arguments

a

a row (column) vector to be converted to a matrix based on its row (column) names.

notation

a string vector created by notation_vec() that identifies the notation for row or column names.

Value

a matrix created from vector a.

Examples

v <- matrix(c(1,
              2,
              3, 
              4), 
            nrow = 4, ncol = 1, dimnames = list(c("p1 -> i1", 
                                                  "p2 -> i1", 
                                                  "p1 -> i2", 
                                                  "p2 -> i2"))) %>% 
  setrowtype("Products -> Industries")
# Default separator is " -> ".
matricize_byname(v, notation = RCLabels::arrow_notation)

matsbyname documentation built on April 2, 2022, 1:06 a.m.