[R] column selection in list

Ivan Calandra ivan.calandra at uni-hamburg.de
Fri Jan 22 17:26:44 CET 2010


Thanks Baptiste, it does help.

However, I don't really understand what "[" means. Could you please tell 
me more about it? I didn't find anything helpful on that in the help.

Thanks in advance
Ivan



Le 1/22/2010 17:19, baptiste auguie a écrit :
> Hi,
>
> Try this,
>
> a = replicate(3, data.frame(x=1:10, y=rnorm(10)), simplify=FALSE)
>
> lapply(a, "[", "y")
>
> HTH,
>
> baptiste
>
> 2010/1/22 Ivan Calandra<ivan.calandra at uni-hamburg.de>:
>    
>> Hi everybody!
>>
>> I have a (stupid) question but I cannot find a way to do it!
>>
>> I have a list like:
>>      
>>> SPECSHOR_tx_Asfc
>>>        
>> $cotau
>>    SPECSHOR Asfc.median
>> 38    cotau    381.0247
>> 39    cotau    154.6280
>> 40    cotau    303.3219
>> 41    cotau    351.2933
>> 42    cotau    156.5327
>> $eqgre
>>     SPECSHOR Asfc.median
>> 145    eqgre    219.5389
>> 146    eqgre    162.5926
>> 147    eqgre    146.3726
>> 148    eqgre    127.6413
>> 149    eqgre    274.2888
>> $gicam
>>     SPECSHOR Asfc.median
>> 263    gicam    174.7445
>> 264    gicam     83.4821
>> 265    gicam    157.6005
>> 266    gicam    153.7519
>> 267    gicam    344.9775
>>
>> I would just like to remove the column "SPECSHOR" (or extract the other one)
>> so that it looks like
>> $cotau
>>     Asfc.median
>> 38        381.0247
>> 39       154.6280
>> 40        303.3219
>> 41        351.2933
>> 42        156.5327
>> etc.
>>
>> How should I do it? I know how to select each element like
>> SPECSHOR_tx_Asfc[[1]], but I don't know how to select a single column within
>> an element.
>>
>> Could you please help me on that?
>>
>> Thanks
>> Ivan
>>
>> ______________________________________________
>> 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.
>>
>>      
>    

-- 
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Institut und Museum
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calandra at uni-hamburg.de


**********
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php



More information about the R-help mailing list