In the database R:
mat <- matrix(c(1,2,3,
4,5,6,
7,8,9), byrow = TRUE, ncol = 3)
R <- apply(mat, 1, prod)
R
sum(R)
R> R
[1] 6 120 504
R> sum(R)
[1] 630
CRAN , matrixStats, rowSums, colSums ( ) R.
install.packages("matrixStats") ## install it from CRAN
## load matrixStats
library("matrixStats")
rowProds(mat)
R> rowProds(mat)
[1] 6 120 504
R> sum(rowProds(mat))
[1] 630