[R] List-manipulation

Tony Plate tplate at acm.org
Fri Sep 29 19:01:24 CEST 2006


Does this do what you want?

 > x <- list(1,2,3:7,8,9:10)
 > sapply(x, function(xx) xx[1])
[1] 1 2 3 8 9
 >

-- Tony Plate

Benjamin Otto wrote:
> Hi,
> 
>  
> 
> Sorry for the question, I know it should be basic knowledge but I'm
> struggling for two hours now.
> 
>  
> 
> How do I select only the first entry of each list member and ignore the
> rest?
> 
>  
> 
> So for 
> 
>  
> 
> 
>>$"121_at"
> 
> 
>>-113691170 
> 
> 
>  
> 
> 
>>$"1255_g_at"
> 
> 
>>42231151 
> 
> 
>  
> 
> 
>>$"1316_at"
> 
> 
>>35472685 35472588 
> 
> 
>  
> 
> 
>>$"1320_at"
> 
> 
>>-88003869
> 
> 
>  
> 
> I only want to select 
> 
>  
> 
> -113691170, 42231151, 35472685 and -88003869 .?
> 
>  
> 
> Regards
> 
> Benjamin
> 
> --
> Benjamin Otto
> Universitaetsklinikum Eppendorf Hamburg
> Institut fuer Klinische Chemie
> Martinistrasse 52
> 20246 Hamburg
> 
>  
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch 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