[R] how to remove "numeric(0)" component from a list

Bill.Venables at csiro.au Bill.Venables at csiro.au
Tue Jun 29 06:42:06 CEST 2010


newlist <- newlist[sapply(newlist, length) > 0] 

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of song song
Sent: Tuesday, 29 June 2010 2:12 PM
To: r-help at r-project.org
Subject: [R] how to remove "numeric(0)" component from a list

like this, the list is below,  I want to remove the last one .  not using
newlist[-2], but using the function detect its component is numeric(0) and
then remove it from the list.

newlist

[[1]]
[1] 2 3

[[2]]
[1] numeric(0)

[[3]]
[1] 7

	[[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