[R] ask a question about list in R

Phil Spector spector at stat.berkeley.edu
Fri Jun 25 07:15:48 CEST 2010


Song -
    Set the element to NULL:

> al=list(c(2,3),5,7)
> al[[2]] = NULL
> al
[[1]]
[1] 2 3

[[2]]
[1] 7

 					- Phil Spector
 					 Statistical Computing Facility
 					 Department of Statistics
 					 UC Berkeley
 					 spector at stat.berkeley.edu




On Thu, 24 Jun 2010, song song wrote:

> my list al is as below:
> al=list(c(2,3),5,7)
>> al
> [[1]]
> [1] 2 3
>
> [[2]]
> [1] 5
>
> [[3]]
> [1] 7
>
> and  I check the second component, its element is 5, then I remove this, now
> my al is:
>
> al[[2]][al[[2]]!=5]->al[[2]]
>> al
> [[1]]
> [1] 2 3
>
> [[2]]
> numeric(0)
>
> [[3]]
> [1] 7
>
> The Question is, how I can get the new list without the second component,
> that is :
>
>> alwanted
> [[1]]
> [1] 2 3
>
> [[2]]
> [1] 7
>
> Thank you for your help!!!
>
> 	[[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