[R] cleaning up after example()

Sundar Dorai-Raj sundar.dorai-raj at pdf.com
Tue Dec 17 17:53:06 CET 2002


> Dear R-help,
> 
> 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?
> 

Andy,
  One quick fix would be to take a snapshot of your current workspace,
then delete anything new afterwards. Of course, this doesn't account for
overwritten variables.

> snapshot = ls()
> example("smooth",pack="eda",lib.loc=.Library)
...
> remove(list = ls()[!ls()%in%snapshot]) # also removes `snapshot'

Regards,
Sundar

-- 
Sundar Dorai-Raj
PDF Solutions, Inc.
Dallas TX




More information about the R-help mailing list