This function is equivalent to a %>% rowsums_byname() %>% colsums_byname()
,
but returns a single numeric value instead of a 1x1 matrix.
sumall_byname(a)
a | the matrix whose elements are to be summed |
---|
the sum of all elements in a
as a numeric
library(dplyr) m <- matrix(2, nrow=2, ncol=2, dimnames = list(paste0("i", 1:2), paste0("c", 1:2))) %>% setrowtype("Industry") %>% setcoltype("Commodity") sumall_byname(m)#> [1] 8#> Commodity #> Industry 8 #> attr(,"rowtype") #> [1] "Industry" #> attr(,"coltype") #> [1] "Commodity"#> [[1]] #> [1] 8 #> #> [[2]] #> [1] 8 #>#> [1] 8sumall_byname(DF$m)#> [[1]] #> [1] 8 #> #> [[2]] #> [1] 8 #>#> [[1]] #> [1] 8 #> #> [[2]] #> [1] 8 #>