[R] Extracting values from a list

Paul Hiemstra p.hiemstra at geo.uu.nl
Fri Feb 19 13:50:07 CET 2010


chipmaney wrote:
> Thanks, as a follow-up, how do i extract the list element name (ie, 4-2 or 44-1)
>   
Look at names(your_list)

cheers,
Paul
> thanks,
>
> chipper
>
> Date: Thu, 18 Feb 2010 11:56:45 -0800
> From: ml-node+1560750-540257540-69226 at n4.nabble.com
> To: chipmaney at hotmail.com
> Subject: Re: Extracting values from a list
>
>
>
> Try this:
>
>
> sapply(x, '[', 'p.value')
>
>
> On Thu, Feb 18, 2010 at 5:21 PM, chipmaney <[hidden email]> wrote:
>
>   
>
>   
>> I have run a kruskal.test() using the by() function, which returns a list of
>>     
>
>   
>> results like the following (subset of results):
>>     
>
>   
>
>   
>> Herb.df$ID: 4-2
>>     
>
>   
>>       Kruskal-Wallis chi-squared = 18.93, df = 7, p-value = 0.00841
>>     
>
>   
>> --------------------------------------------------------------------
>>     
>
>   
>> Herb.df$ID: 44-1
>>     
>
>   
>>        Kruskal-Wallis chi-squared = 4.43, df = 6, p-value = 0.6187
>>     
>
>   
>
>   
>
>   
>> So then, how do extract a vector of p-values (i.e., result$p.value) for
>>     
>
>   
>> every element in the list?
>>     
>
>   
>
>   
>
>   
>
>   
>> --
>>     
>
>   
>> View this message in context: http://n4.nabble.com/Extracting-values-from-a-list-tp1560701p1560701.html
>> Sent from the R help mailing list archive at Nabble.com.
>>     
>
>   
>
>   
>> ______________________________________________
>>     
>
>   
>> [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
>> and provide commented, minimal, self-contained, reproducible code.
>>     
>
>   
>
>
>
>   
> ------------------------------------------------------------------------
>
> ______________________________________________
> 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.
>   


-- 
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +3130 274 3113 Mon-Tue
Phone:  +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~paul



More information about the R-help mailing list