[R] remove empty objects from workspace
Jim Lemon
jim at bitwrit.com.au
Tue May 19 13:24:43 CEST 2009
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
More information about the R-help
mailing list