This function transposes row and column names as well as row and column types. Rows and columns of a are sorted prior to inverting.

invert_byname(a)

Arguments

a

the matrix to be inverted. a must be square.

Value

the inversion of a

Examples

m <- matrix(c(10,0,0,100), nrow = 2, dimnames = list(paste0("i", 1:2), paste0("c", 1:2))) %>% setrowtype("Industry") %>% setcoltype("Commodity") invert_byname(m)
#> i1 i2 #> c1 0.1 0.00 #> c2 0.0 0.01 #> attr(,"rowtype") #> [1] "Commodity" #> attr(,"coltype") #> [1] "Industry"
matrixproduct_byname(m, invert_byname(m)) matrixproduct_byname(invert_byname(m), m) invert_byname(list(m,m))
#> [[1]] #> i1 i2 #> c1 0.1 0.00 #> c2 0.0 0.01 #> attr(,"rowtype") #> [1] "Commodity" #> attr(,"coltype") #> [1] "Industry" #> #> [[2]] #> i1 i2 #> c1 0.1 0.00 #> c2 0.0 0.01 #> attr(,"rowtype") #> [1] "Commodity" #> attr(,"coltype") #> [1] "Industry" #>