On Sat, Apr 9, 2011 at 3:27 PM, Barry Rowlingson
wrote:
> On Sat, Apr 9, 2011 at 6:29 PM, Benjamin Tyner wrote:
>
>>> The above feels a bit like snooping where I wasn't invited.
>>> You could do something like
>>> mq <- function(a) {
>>> force(a)
>>> list(getA = function()a,
>>>
On Sat, Apr 9, 2011 at 6:29 PM, Benjamin Tyner wrote:
>> The above feels a bit like snooping where I wasn't invited.
>> You could do something like
>> mq <- function(a) {
>> force(a)
>> list(getA = function()a,
>> setA = function(newA) a <<- newA,
>> fun = function(x)x^
Thanks Bill and Gabor!
William Dunlap wrote:
-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of Benjamin Tyner
Sent: Friday, April 08, 2011 6:48 PM
To: r-help@r-project.org
Subject: [R] best practice(s) for retrieving a local
> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of Benjamin Tyner
> Sent: Friday, April 08, 2011 6:48 PM
> To: r-help@r-project.org
> Subject: [R] best practice(s) for retrieving a local variable
> from a c
On Fri, Apr 8, 2011 at 9:48 PM, Benjamin Tyner wrote:
> Greetings,
>
> Say I have defined
>
> mp <- function(a) function(x) x^a
>
> f2 <- mp(2)
>
> and I would like to retrieve the "a" which is local to f2. Two options come
> to mind;
>
> get("a", envir=environment(f2))
> eval(substitute(a), e
Greetings,
Say I have defined
mp <- function(a) function(x) x^a
f2 <- mp(2)
and I would like to retrieve the "a" which is local to f2. Two options
come to mind;
get("a", envir=environment(f2))
eval(substitute(a), environment(f2))
I'm curious if one of these is preferred over the other
6 matches
Mail list logo