Dear list, is there a function in R that returns the product of a vector? E.g. if the vector is c(1,2,3,4) it should return 1*2*3*4=24 Cheers Jannis
Is this what you want:> prod(c(1,2,3,4))[1] 24>On Thu, Jan 20, 2011 at 12:18 PM, Jannis <bt_jannis at yahoo.de> wrote:> Dear list, > > > is there a function in R that returns the product of a vector? > > E.g. if the vector is c(1,2,3,4) it should return 1*2*3*4=24 > > > Cheers > Jannis > > > > > > > ______________________________________________ > R-help at r-project.org 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. >-- Jim Holtman Data Munger Guru What is the problem that you are trying to solve?
Take a look in prod function: prod(1:4) On Thu, Jan 20, 2011 at 3:18 PM, Jannis <bt_jannis@yahoo.de> wrote:> Dear list, > > > is there a function in R that returns the product of a vector? > > E.g. if the vector is c(1,2,3,4) it should return 1*2*3*4=24 > > > Cheers > Jannis > > > > > > > ______________________________________________ > R-help@r-project.org 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. >-- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]