Hi! I have a list of 24 elements, all of the same type (dataframe, for example). I am looking for an alternative to mylist[[1]] + mylist[[2]] + ... + mylist[[24]] to obtain the sum. Anyone can help me? Thanks in advance. Nicola S. [[alternative HTML version deleted]]
Have a look at Reduce(), e.g., Reduce("+", your.list) I hope it helps. Best, Dimitris On 7/27/2010 2:36 PM, Nicola Sturaro Sommacal wrote:> Hi! > > I have a list of 24 elements, all of the same type (dataframe, for example). > > I am looking for an alternative to mylist[[1]] + mylist[[2]] + ... + > mylist[[24]] to obtain the sum. > > Anyone can help me? > > Thanks in advance. > > Nicola S. > > [[alternative HTML version deleted]] > > ______________________________________________ > 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. >-- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014
Hi, do.call(sum, mylist) ?do.call baptiste On 27 July 2010 14:36, Nicola Sturaro Sommacal <mailinglist at nicolasturaro.com> wrote:> Hi! > > I have a list of 24 elements, all of the same type (dataframe, for example). > > I am looking for an alternative to mylist[[1]] + mylist[[2]] + ... + > mylist[[24]] to obtain the sum. > > Anyone can help me? > > Thanks in advance. > > Nicola S. > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > 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. >