Skip to content
Back to formatted view

Raw Message

Message-ID: <971536df0505120709d0133a@mail.gmail.com>
Date: 2005-05-12T14:09:00Z
From: Gabor Grothendieck
Subject: assigning to a list in a package environment
In-Reply-To: <c6192184b8423427f853348ca8ae08d4@mail.nih.gov>

On 5/11/05, Sean Davis <sdavis2 at mail.nih.gov> wrote:
> I have a list in a package environment
> 
> assign('refflat',list(),pos='package:locPkg')
> 
> to which I would like to make assignments like:
> 
> refflat[['a']] <- read.table('fileA.txt')
> refflat[['b']] <- read.table('fileB.txt')
> 
> I am doing this to guard against a local version of refflat hanging
> around, as I want to refresh it with each new session (and so, want to
> store it in the package environment).  I just can't quite get hot to
> make that work so that I am storing to the package:refflat rather than
> any in .GlobalEnv.

Try this:

locPkg <- as.environment("package:locPkg")
locPkg$refflat <- list()
locPkg$refflat[["a"]] <- read.table("fileA.txt")