[R] how to extract from list

Rui Barradas ruipbarradas at sapo.pt
Tue Oct 16 13:34:49 CEST 2012


Hello,

Try the following.

lapply(lst, `[[`, 'kappa')

Also, please post a data example using ?dput, in case of lists it's 
difficult for us to reproduce what you've posted.

Hope this helps,

Rui Barradas
Em 16-10-2012 12:17, Balqis escreveu:
> Hi all,
>
> I have a list of 20000 data, and the list look like below. I wonder what is
> the simplest way to extract 'kappa' value (or 'xi' or 'alpha' for the
> matter)  from each of the data. How can I simply code it without having to
> change the list to a dataframe first? Many thanks!
>
>
> $X19997
>           xi       alpha       kappa
> 784.7718640 165.4065141  -0.2709599
>
> $X19998
>           xi       alpha       kappa
> 860.7832604 215.1144980  -0.1769741
>
> $X19999
>           xi       alpha       kappa
> 839.7692675 196.0103874  -0.3848809
>
> $X20000
>           xi       alpha       kappa
> 847.6117040 212.3279185  -0.2576029
>
> regards,
> aehan
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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.




More information about the R-help mailing list