Jose Quesada said the following on 5/7/2007 11:25 AM:
> 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
> 

Try: apply(x,2,prod)

HTH,

--sundar

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to