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? Cheers, Andy ------------------------------------------------------------------------------
cleaning up after example()
6 messages · Liaw, Andy, Brian Ripley, Michel ARNAUD +3 more
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
Hi I would like to plot hist and density associated on the same graph. I don't find the code. Any suggestions ? -- Michel ARNAUD CIRAD TA60/15 73, av. Jean Fran?ois Breton 34938 MONTPELLIER CEDEX 5 tel : 04 67 59 38 34 Fax : 04 67 59 38 38 -------------- next part -------------- A non-text attachment was scrubbed... Name: michel.arnaud.vcf Type: text/x-vcard Size: 204 bytes Desc: Carte pour Michel ARNAUD Url : https://stat.ethz.ch/pipermail/r-help/attachments/20021217/133d56c2/michel.arnaud.vcf
An HTML attachment was scrubbed... URL: https://stat.ethz.ch/pipermail/r-help/attachments/20021217/4665d73f/attachment.html
Hello, Yes, you have some examples in the "histogram" command in the lattice library. Regards, Carlos. -----Mensaje original----- De: r-help-admin at stat.math.ethz.ch [mailto:r-help-admin at stat.math.ethz.ch]En nombre de Michel ARNAUD Enviado el: martes, 17 de diciembre de 2002 15:38 Para: 'r-help at stat.math.ethz.ch' Asunto: [R] hist and density on the same plot Hi I would like to plot hist and density associated on the same graph. I don't find the code. Any suggestions ? -- Michel ARNAUD CIRAD TA60/15 73, av. Jean Fran?ois Breton 34938 MONTPELLIER CEDEX 5 tel : 04 67 59 38 34 Fax : 04 67 59 38 38 _____ The information in this email is confidential and it may not be\ ... [[dropped]]
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