Try this:

mean(unlist(sapply(listobject[1:5], '[', 'element')))

On Wed, Dec 15, 2010 at 11:22 AM, Jim Maas <jimmaasuk@gmail.com> 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)
>
> to get the mean of "element" in the first five components?
>
> It doesn't like the $.  I'm suspect one of the "apply" functions will work,
> but again I've not had success
>
>
> Thanks a bunch.
>
> J
>
> ----
> Jim Maas
> University of East Anglia
>
> ______________________________________________
> 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]]

