Re: [Rd] Scoping issues

From: John Fox <>
Date: Sun 07 Jan 2007 - 13:57:27 GMT

Dear Chris,

If I correctly understand what you want to do, the Rcmdr package uses the following functions (slightly modified from original version contributed by Philippe Grosjean) to solve a similar problem:

RcmdrEnv <- function() {

    pos <- match("RcmdrEnv", search())
    if ( { # Must create it

        RcmdrEnv <- list()
        attach(RcmdrEnv, pos = length(search()) - 1)
        pos <- match("RcmdrEnv", search())


putRcmdr <- function(x, value)

    assign(x, value, envir = RcmdrEnv())

getRcmdr <- function(x, mode="any")

    get(x, envir = RcmdrEnv(), mode = mode, inherits = FALSE)

I hope this helps,

John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4

> -----Original Message-----
> From:
> [] On Behalf Of Chris Eisley
> Sent: Sunday, January 07, 2007 12:29 AM
> To:
> Subject: [Rd] Scoping issues
> Hi everyone,
> I'm trying to split up a large R file that implements a
> tcl/tk gui into several smaller ones. The problem is that
> the main GUI creation function defines many tclVars and
> tkframes that need to be accessible to functions that are
> currently defined in main function, but which I'd like to
> move to different source files. These files make up a
> package, so it seems that using source() is a bad idea. I
> could try argument passing, but there are a lot of arguments
> to pass in some cases.
> The lexical scoping is hurting me here, but I assume there's
> a good way to deal with this kind of issue. Any help is
> greatly appreciated.
> -Chris
> ______________________________________________
> mailing list
> mailing list Received on Mon Jan 08 05:53:53 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 08 Jan 2007 - 00:31:36 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.