[R] automatic cleaning of workspace

rolf at math.unb.ca rolf at math.unb.ca
Tue Nov 28 14:02:47 CET 2006


I believe the following function is something like what Mark was
looking for.  The previously posted answers to his inquiry were more
of the form ``Do this instead of what you want to do.'' rather than
``Here's how to do what you want to do.''

clean <- function()
{
# Function clean.
        lll <- ls(pos=1)
        for(xxx in lll) {
                pmpt <- paste("remove ", xxx, "? ",sep="")
                ans <- readline(pmpt)
                if(ans == "y")
                        rm(list=xxx, pos = 1)
        }
        invisible()
}

Usage: clean()

				cheers,

					Rolf Turner
					rolf at math.unb.ca

P. S.  Moral of the story:  If you want to do something in R
and the facility is not built in, it is usually very easy to
roll your own.  Often it's actually easier to roll your own
than to *find* pre-existing facilities.

					R. T.



More information about the R-help mailing list