[R] More on global environment

Mike Prager Mike.Prager at noaa.gov
Thu Jul 15 21:36:06 CEST 2004


At 7/15/2004 03:23 PM Thursday, Andy Liaw wrote:
>I've posted the following to R-help before.  Hope it helps you.
>
>cd <- function(dir = tclvalue(tkchooseDirectory()), saveOld=FALSE,
>                loadNew=TRUE) {
>     stopifnot(require(tcltk))

         flush.console()

>     if (saveOld) save.image(compress=TRUE)
>     setwd(dir)
>     rm(list=ls(all=TRUE, envir=.GlobalEnv), envir=.GlobalEnv)
>     if (loadNew && file.exists(".RData")) {
>         loaded <- load(".RData", envir=.GlobalEnv)
>         return(invisible(loaded))
>     }
>}
>
>[The tcltk part is based on Prof. Fox's help.]
>
>Andy

Thanks!  It's lovely.  I added the call to flush.console() as shown, which 
(under Windows RGUI at least) issues the message that tcl is loading in a 
more timely way.

Mike




More information about the R-help mailing list