Hi,
how can I remove all empty objects (which are NA or have zero rows)
from my workspace?
Thanks,
Katharina
remove empty objects from workspace
4 messages · Katharina May, Jim Lemon, Henrique Dallazuanna
Katharina May wrote:
Hi, how can I remove all empty objects (which are NA or have zero rows) from my workspace?
Hi Katharina, To remove objects that are all NA: for(object in objects()) if(all(is.na(get(object)))) rm(list=object) If by "zero rows" you mean objects that do not have a dimension: for(object in objects()) if(is.null(dim(get(object)))) rm(list=object) Jim
Thanks Jim, the removal of objects which are NA works perfectly! For my second problem it didn't express myself correctly: I actually meant objects with rows (attributes?) but no data in it but I solved this adjusting your approach: for(object in objects()) if(is.null(dim(get(object))[1]) || dim((get(object)))[1] == 0) rm(list=object) Thanks a lot! 2009/5/19 Jim Lemon <jim at bitwrit.com.au>:
Katharina May wrote:
Hi, how can I remove all empty objects (which are NA or have zero rows) from my workspace?
Hi Katharina, To remove objects that are all NA: for(object in objects()) if(all(is.na(get(object)))) rm(list=object) If by "zero rows" you mean objects that do not have a dimension: for(object in objects()) if(is.null(dim(get(object)))) rm(list=object) Jim
Time flies like an arrow, fruit flies like bananas.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090519/3a89ad4d/attachment-0001.pl>