This function is equivalent to a %>% rowprods_byname() %>% colprods_byname()
,
but returns a single numeric value instead of a 1x1 matrix.
prodall_byname(a)
a | the matrix whose elements are to be multiplied |
---|
the product 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("Product") prodall_byname(M)#> [1] 16#> Product #> Industry 16 #> attr(,"rowtype") #> [1] "Industry" #> attr(,"coltype") #> [1] "Product"#> [[1]] #> [1] 16 #> #> [[2]] #> [1] 16 #>#> [1] 16prodall_byname(DF$M)#> [[1]] #> [1] 16 #> #> [[2]] #> [1] 16 #>#> [[1]] #> [1] 16 #> #> [[2]] #> [1] 16 #>