Sven Garbade wrote:> > Hi, > > how can I remove all R objects in the workspace out of a function? > rm(list=ls()) doesn't work, and I've tried several pos arguments, but > nothing worked.Example: anything <- 1 delete.all <- function() rm(list=ls(pos=.GlobalEnv), pos=.GlobalEnv) delete.all() ls() Uwe Ligges -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hi, how can I remove all R objects in the workspace out of a function? rm(list=ls()) doesn't work, and I've tried several pos arguments, but nothing worked. Thanks, Sven -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Dear Sven, At 01:27 PM 3/5/2002 +0000, you wrote:>Hi, > >how can I remove all R objects in the workspace out of a function? >rm(list=ls()) doesn't work, and I've tried several pos arguments, but >nothing worked.This seems like a rather risky thing to do; however: > suicide <- function() rm(list=ls(.GlobalEnv) , envir=.GlobalEnv) > x <- y <- z <- 1 > ls() [1] "suicide" "x" "y" "z" > suicide() > ls() character(0) Is that what you had in mind? (Of course, the function need not reside in the global environment.) John ----------------------------------------------------- John Fox Department of Sociology McMaster University Hamilton, Ontario, Canada L8S 4M4 email: jfox at mcmaster.ca phone: 905-525-9140x23604 web: www.socsci.mcmaster.ca/jfox ----------------------------------------------------- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._