Re: [R] Selectively Removing objects

2009-02-02 Thread Carl Witthoft
Slightly related to this (I think Mr. Rydevik's code solved the question), is a silly thing I wrote up one weekend. It started out as a clone of the unix "rm -i" command, and kept on going out of control :-) I'm not claiming this is clean, or the best way to do this, but it does let you appl

Re: [R] Selectively Removing objects

2009-02-02 Thread Paulo Grahl
Thanks Greg. I did in the past looked into the details of how to create a package. I did not seem too complicated, but it would be time consuming -- an then when one thinks in creating a package (even for his own use) it always a good idea to check for wrong inputs, to have all functions well docu

Re: [R] Selectively Removing objects

2009-02-02 Thread Greg Snow
If you want to keep the functions, why not move them to a different environment so that they don't get deleted when you delete everything else (this will also work better if you want to use these same functions in other R sessions). The most comprehensive way to do this is to create a package wi

Re: [R] Selectively Removing objects

2009-02-02 Thread Paulo Grahl
Thank you all for the prompt answer !! It did solve my problem perfectly ! Rgds, Paulo On Mon, Feb 2, 2009 at 11:51 AM, Kenn Konstabel wrote: > You can get a list of all functions in your workspace with > > ls()[sapply(ls(), function(x) is.function(get(x)))] > # or ls()[sapply(sapply(ls(),

Re: [R] Selectively Removing objects

2009-02-02 Thread Kenn Konstabel
You can get a list of all functions in your workspace with ls()[sapply(ls(), function(x) is.function(get(x)))] # or ls()[sapply(sapply(ls(), get), is.function)] Removing everything else is rm(list=ls()[sapply(ls(), function(x) !is.function(get(x)))]) # or rm(list=ls()[!sapply(sapply(ls(), ge

Re: [R] Selectively Removing objects

2009-02-02 Thread Duncan Murdoch
On 02/02/2009 8:16 AM, Paulo Grahl wrote: Dear list members, Does anyone know how to use rm() to remove only variables but not declared functions from the environment ? I understand I could name all the functions with, let's say "f_something", make sure that all variables do not start with "f_"

Re: [R] Selectively Removing objects

2009-02-02 Thread Gustaf Rydevik
On Mon, Feb 2, 2009 at 2:16 PM, Paulo Grahl wrote: > Dear list members, > > Does anyone know how to use rm() to remove only variables but not > declared functions from the environment ? > I understand I could name all the functions with, let's say > "f_something", make sure that all variables do n

Re: [R] Selectively Removing objects

2009-02-02 Thread Ben Bolker
Paulo Grahl gmail.com> writes: > > Dear list members, > > Does anyone know how to use rm() to remove only variables but not > declared functions from the environment ? > I understand I could name all the functions with, let's say > "f_something", make sure that all variables do not start with "