[R] cleaning up after example()
ripley@stats.ox.ac.uk
ripley at stats.ox.ac.uk
Tue Dec 17 08:20:04 CET 2002
On Mon, 16 Dec 2002, Liaw, Andy wrote:
> I find the example() function is extremely useful in many ways. However,
> there's a minor inconvenience: for long examples, it leaves lots of objects
> in the workspace. While it's sometimes useful to have the objects around
> for further exploration, other times they just add to the clutter. Does
> anyone have a good way of cleaning up afterward? If not, would R core
> consider adding such a feature?
It's half there. Example calls source, and source has a local argument
that by default uses the workspace for objects. We just need to call
source(local=TRUE) in example(), and then the objects will get created in
the frame of the example call.
This BTW is to avoid creating the objects, not cleaning up. It is not
possible (AFAIK) to find out what objects have been created, nor to know
if they clobber existing objects of the same name.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list