[R] like apply(x,1,sum), but using multiplication?

Jose Quesada quesada at gmail.com
Mon May 7 20:25:06 CEST 2007


Hi,

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.

Thanks,
-Jose

-- 
Jose Quesada, PhD.
http://www.andrew.cmu.edu/~jquesada



More information about the R-help mailing list