R: mean from list

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

R: mean from list

statistical.model
great!! thanks very much, mean(unlist(lapply(listdata, function(z) z$c)))
works well.
and what about getting the average table $a (displaying the average elements
across all 1000 matrix)? could you please help me? I am struggling with
this...

thanks in advance
Roberto



mean(unlist(lapply(x, function(z) z$d))) should do the trick

On Sun, 12 Feb 2006 20:06:12 +0000, [hidden email] wrote:

> 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
>
>
>

Rajarshi Guha
<[hidden email]>
<http://jijo.cjb.net>

----------------------------------------
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: R: mean from list

Kjetil Halvorsen
[hidden email] wrote:
> great!! thanks very much, mean(unlist(lapply(listdata, function(z) z$c)))

WHY unlist(lapply(...   when sapply(...
is simpler?

Kjetil


> works well.
> and what about getting the average table $a (displaying the average elements
> across all 1000 matrix)? could you please help me? I am struggling with
> this...
>
> thanks in advance
> Roberto
>
>
>
> mean(unlist(lapply(x, function(z) z$d))) should do the trick
>
> On Sun, 12 Feb 2006 20:06:12 +0000, [hidden email] wrote:
>
>> 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
>>
>>
>
> Rajarshi Guha
> <[hidden email]>
> <http://jijo.cjb.net>
>
> ----------------------------------------
> 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

______________________________________________
[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: R: mean from list

Rajarshi Guha
On Sun, 2006-02-12 at 19:21 -0400, Kjetil Brinchmann Halvorsen wrote:
> [hidden email] wrote:
> > great!! thanks very much, mean(unlist(lapply(listdata, function(z) z$c)))
>
> WHY unlist(lapply(...   when sapply(...
> is simpler?

Aah! Immediately after sending it I realized the simpler form :-/

-------------------------------------------------------------------
Rajarshi Guha <[hidden email]> <http://jijo.cjb.net>
GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE
-------------------------------------------------------------------
Finally I am becoming stupider no more
- Paul Erdos' epitaph

______________________________________________
[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