multiplying all elements of a vector in R
You want prod
:
R> prod(1:3)
[1] 6
If your data is all greater than zero this is a safer solution that will not cause compute overflows:
exp(sum(log(x)))
You want prod
:
R> prod(1:3)
[1] 6
If your data is all greater than zero this is a safer solution that will not cause compute overflows:
exp(sum(log(x)))