mean from list

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

mean from list

statistical.model
hi all,
I have a simple problem that i am not able to solve. I've a list called
datalist with the following structure:

[...]

[[10]]
[[10]]$a

     -1  0  1
  -1 31  5  2
  0   6  7  5
  1   1  7 36

[[10]]$b

     -1  0  1
  -1 31  5  2
  0   6  7  5
  1   1  7 36

[[10]]$c
[1] 0.855

[[10]]$d
[1] 0.855

[...]

with [[1]] ... [[100]]. How can i get the mean value of datalist[[x]]$d,
where x represents all elements from 1 to 1000 ?

thanks in advance!!!!

Roberto Furlan
University of Turin

----------------------------------------
La mia Cartella di Posta in Arrivo è protetta da SPAMfighter
205 messaggi contenenti spam sono stati bloccati con successo.
Scarica gratuitamente SPAMfighter!

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: mean from list

Peter Dalgaard
[hidden email] writes:

> hi all,
> I have a simple problem that i am not able to solve. I've a list called
> datalist with the following structure:
>
> [...]
>
> [[10]]
> [[10]]$a
>
>      -1  0  1
>   -1 31  5  2
>   0   6  7  5
>   1   1  7 36
>
> [[10]]$b
>
>      -1  0  1
>   -1 31  5  2
>   0   6  7  5
>   1   1  7 36
>
> [[10]]$c
> [1] 0.855
>
> [[10]]$d
> [1] 0.855
>
> [...]
>
> with [[1]] ... [[100]]. How can i get the mean value of datalist[[x]]$d,
> where x represents all elements from 1 to 1000 ?

I'd try something like

mean(sapply(x,"[[","d"))
 

--
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - ([hidden email])                  FAX: (+45) 35327907

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html