Row product of matrix and column sum of matrix
matrix, r
Solution
sum(apply(A, 1, prod))
apply the prod function across the rows (the 1 is the margin), sum the result.
Problem
I have a matrix of size TxR and I am looking for a command to do the product of the rows (returning an 1 x R vector of the products). After that I want to sum over the columns, i.e. sum the R terms. In Matlab this would be done something like this sum(prod(A,1),2), but I don't know the code for this in R. I hope it make sense. Thanks