Hi, I know it must be written somewhere but I can't find it. I'd like to remove all variables or objects that I've created but not the functions. I look at a few things without success. Is there a R way of doing this? There are to many to create a manual list. Thanks in advance. Yves Gauvreau -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
"Yves Gauvreau" <cyg at sympatico.ca> writes:> I know it must be written somewhere but I can't find it. > > I'd like to remove all variables or objects that I've created but not the > functions. I look at a few things without success. Is there a R way of doing > this? There are to many to create a manual list.The preferred way to do this is to create a private R package of your functions. The manual "Writing R Extensions" available in the doc/manual section of the sources and in many of the binary distributions describes how to do this. It may seem overkill to do this initially but it later becomes a very valuable technique for keeping projects distinct. It is worth the time spent learning to do this. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Tue, Oct 17, 2000 at 09:06:11AM -0400, Yves Gauvreau wrote:> Hi, > > I know it must be written somewhere but I can't find it. > > I'd like to remove all variables or objects that I've created but not the > functions. I look at a few things without success. Is there a R way of doing > this? There are to many to create a manual list. >You can try something like> ls()character(0)> a<-1 > b<-2 > f<-function(x) x+1 > ls()[1] "a" "b" "f"> rm(list=ls()[!sapply(ls(),function(x)exists(x,mode="function"))]) > ls()[1] "f" but,..., be carefull, look to the result of 'sapply' before doing the true 'rm'. guido -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hello, a bit complicated but a quick solution:> as <- function(x) { eval(as.name(x)) } > rm(list=ls()[! sapply(sapply(ls(),"as"),"is.function")])jan On Tue, 17 Oct 2000, Yves Gauvreau wrote:> Hi, > > I know it must be written somewhere but I can't find it. > > I'd like to remove all variables or objects that I've created but not the > functions. I look at a few things without success. Is there a R way of doing > this? There are to many to create a manual list. > > Thanks in advance. > > Yves Gauvreau > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._-- ----------------------------------- Jan Goebel (mailto:jgoebel at diw.de) DIW German Institute for Economic Research SOEP K?nigin-Luise-Str. 5 D-14195 Berlin Germany phone: 49 30 89789-377 ----------------------------------- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._