Learn R Programming

matsbyname (version 0.6.4)

matricize_byname: Matricize a vector

Description

Converts a vector with rows or columns named according to notation into a matrix or a Matrix, depending on the type of a.

Usage

matricize_byname(a, notation)

Value

A matrix created from vector a.

Arguments

a

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

notation

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

Examples

Run this code
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)

Run the code above in your browser using DataLab