[R] like apply(x,1,sum), but using multiplication?
bcarvalh at jhsph.edu
Mon May 7 20:32:37 CEST 2007
On May 7, 2007, at 2:25 PM, Jose Quesada wrote:
> I need to multiply all columns in a matrix so something like
> apply(x,2,sum), but using multiplication should do.
> I have tried apply(x,2,"*")
> I know this must be trivial, but I get:
> Error in FUN(newX[, i], ...) : invalid unary operator
> The help for apply states that unary operators must be quoted. I tried
> single quotes too, with the same results.
> Jose Quesada, PhD.
> R-help at stat.math.ethz.ch mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help