From daniel.kaschek at physik.uni-freiburg.de  Sun Feb  7 14:08:09 2016
From: daniel.kaschek at physik.uni-freiburg.de (Daniel Kaschek)
Date: Sun, 07 Feb 2016 14:08:09 +0100
Subject: [Rd] Assignment in environment
Message-ID: <1454850489.16166.0@physik.uni-freiburg.de>

Dear all,

I have a function "fn" with its own environment, i.e.

env <- environment(fn)

and env is not .GlobalEnv. And another function

getValue <- function(x) environment(x)$mylist

which returns the list object "mylist" which is in "env". If I want to 
modify "mylist", I could write

'getValue<-' <- function(x, value) { environment(x)$mylist <- value}

which gives not the desired result, e.g.

getValue(fn)[[1]] <- 3

will set the first list entry of "mylist" to 3. But then "fn" will also 
be 3!

environment(fn)$mylist[[1]] <- 3

does set the list entry correctly while keeping "fn". What's the 
difference?

Cheers,
Daniel



[Rd] Assignment in environment
Daniel Kaschek