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

From: Benilton Carvalho <bcarvalh_at_jhsph.edu>
Date: Mon, 07 May 2007 14:32:37 -0400

see

?prod

b

On May 7, 2007, at 2:25 PM, Jose Quesada wrote:

> 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
>
> ______________________________________________
> R-help_at_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.



R-help_at_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. Received on Mon 07 May 2007 - 18:40:28 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 07 May 2007 - 19:31:01 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.