In addition to what Charles wrote, you can also use 'local' if you don't
want a function that creates another function.
> f <- local({info <- 10; function(x) x + info})
> f(3)
[1] 13
best,
Mark
Op vr 11 dec. 2015 om 03:27 schreef Charles C. Berry :
> On Thu, 10 Dec 2015,
On Fri, Dec 11, 2015 at 12:49 AM, Konrad Rudolph
wrote:
>
> On the chance that I’m trying to solve the wrong Y to an X/Y problem,
> the full context to the above problem is explained in [1]. In a
> nutshell, I am hooking a new environment into a function’s
@Jeroen, here’s what I’m solving with my hacking the parent
environment chain: I’m essentially re-implementing `base::attach` —
except that I’m attaching objects *locally* in the function instead of
globally. I don’t think this can be done in any way except by
modifying the parent environment
Thanks. I know about `local` (and functions within functions). In
fact, the functions are *already* defined inside their own environment
(same as what `local` does). But unfortunately this doesn’t solve my
problem, since the functions’ parent environment gets changed during
the function’s
On Fri, Dec 11, 2015 at 1:26 PM, Hadley Wickham wrote:
> Why not use your own S3 class?
Yes, I’ll probably do that. Thanks. I honestly don’t know why I hadn’t
thought of that before, since I’m doing the exact same thing in
another context [1].
[1]:
On Thu, Dec 10, 2015 at 5:49 PM, Konrad Rudolph
wrote:
> I’ve got the following scenario: I need to store information about an
> R function, and retrieve it at a later point. In other programming
> languages I’d implement this using a dictionary with the
On Thu, 10 Dec 2015, Konrad Rudolph wrote:
I’ve got the following scenario: I need to store information about an
R function, and retrieve it at a later point. In other programming
languages I’d implement this using a dictionary with the functions as
keys. In R, I’d usually use `attr(f,