[R] Removing objects from a list based on nrow
Tim Clark
mudiver1200 at yahoo.com
Sun Nov 29 09:36:50 CET 2009
Dear List,
I have a list containing data frames of various numbers of rows. I need to remove any data frame that has less than 3 rows. For example:
df1<-data.frame(letter=c("A","B","C","D","E"),number=c(1,2,3,4,5))
df2<-data.frame(letter=c("A","B"),number=c(1,2))
df3<-data.frame(letter=c("A","B","C","D","E"),number=c(1,2,3,4,5))
df4<-data.frame(letter=c("A","B","C","D","E"),number=c(1,2,3,4,5))
lst<-list(df1,df2,df3,df4)
How can I determine that the second object (df2) has less than 3 rows and remove it from the list?
Thanks!
Tim
Tim Clark
Department of Zoology
University of Hawaii
More information about the R-help
mailing list