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

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 = arrow_notation())
#> i1 i2 #> p1 1 3 #> p2 2 4 #> attr(,"rowtype") #> [1] "Products" #> attr(,"coltype") #> [1] "Industries"