On Jun 25, 2010, at 1:00 AM, 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
Another way:
> al=list(c(2,3),5,7)
> al[-2]
[[1]]
[1] 2 3
[[2]]
[1] 7
> alwanted <- al[-2]
Negative indexing with the "[" operator.
--
David.
______________________________________________
R-help@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.