[R] product of vector elements

Daniel Nordlund res90sx5 at verizon.net
Sun Jan 13 01:55:51 CET 2008


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf
> Of Gerard Smits
> Sent: Saturday, January 12, 2008 4:39 PM
> To: r-help at r-project.org
> Subject: [R] product of vector elements
> 
> All,
> 
> I would like to find a simper method that I now have to find the
> product of all elements  in a vector:
> 
> #get product of vector elements: (1,2,3,4,5)
> vec.product <- exp(sum(log(c(1,2,3,4,5))))
> 
> I have not found a vector product function, if one has been written.
> 
> Thanks,
> 
> Gerard

See ?prod.

Hope this is helpful,

Dan

Daniel Nordlund
Bothell, WA  USA




More information about the R-help mailing list