Re: [R] calculating mean of list components

2010-12-15 Thread Liviu Andronic
On Wed, Dec 15, 2010 at 2:22 PM, Jim Maas wrote: > I get a list object from an iterative function.  I'm trying to figure out > the most efficient way to calculate the mean of one element, across all > components of the overall list. > > I've tried > > output <- mean (listobject[[1:5]]$element) > >

Re: [R] calculating mean of list components

2010-12-15 Thread Henrique Dallazuanna
Try this: mean(unlist(sapply(listobject[1:5], '[', 'element'))) On Wed, Dec 15, 2010 at 11:22 AM, Jim Maas wrote: > I get a list object from an iterative function. I'm trying to figure out > the most efficient way to calculate the mean of one element, across all > components of the overall lis