Displaying 20 results from an estimated 5000 matches similar to: "Using and 'eval' and environments with active bindings"
2005 Apr 06
1
makeActiveBinding warning
A while ago Luke Tierney remarked that the warning associated with
'makeActiveBinding'-- "saved workspaces with active bindings may not
work properly when loaded into older versions of R"-- should probably be
removed in R-devel. It's still cropping up *sporadically* with R-alpha
of 3/4/2004, but not every time I call 'makeActiveBinding'.
So, two questions:
(i) is it
2020 May 24
1
Surpising behavior when using an active binding as loop index in R 4.0.0
A shorter reproducible example:
example(makeActiveBinding)
for (fred in 1:3) { 0 }
ls()
Both problems go away if you first do
compiler::enableJIT(2)
So looks like a bug in compiling the for loop.
-Deepayan
On Sat, May 23, 2020 at 5:45 PM Thomas Friedrichsmeier via R-devel
<r-devel at r-project.org> wrote:
>
> Possibly just a symptom of the earlier behavior, but I'll amend my
2009 Nov 05
2
Active bindings in attached environments
Hi,
I was wondering if this is expected behavior for active bindings in
attached environments, or if this is a bug:
> e <- new.env()
> makeActiveBinding('x',function() 'foo',e)
> ls(e)
[1] "x"
> attach(e)
> search()
[1] ".GlobalEnv" "e" "package:graphics"
[4] "package:grDevices"
2010 Jan 06
1
MakeActiveBinding help needed
Hi,
I wanted a Q&D way to open a new graphics window but keep the focus in
the console window (under Windows and the Rgui), so I wrote a line into
my Rprofile.site file as follows:
invisible(makeActiveBinding('newdev', function(...)
dev.new(restoreConsole=T), .GlobalEnv))
(That is all on one line, incase the mailer re-parses it). This gives me
a command "newdev" which
2010 Aug 21
1
Speed improvement to evalList
I've been inspired to look at the R source code by some strange timing
results that I wrote about on my blog at radfordneal.wordpress.com
(see the posts on "Speeding up parentheses..." and "Two surprising
things...".
I discovered that the strange speed advantage of curly brackets over
parentheses is partially explained by an inefficiency in the evalList
and
2020 May 23
2
Surpising behavior when using an active binding as loop index in R 4.0.0
Hi,
I stumbled upon a surprising behavior when using an active binding as a
loop index variable in R 4.0.0. In contrast, the behavior observed in R
3.6.1 is in line with my expectations.
Consider the code below:
makeActiveBinding("i",
function(value) {
if (missing(value)) {
x
} else {
print("set")
x <<- value
}
}, globalenv())
i <- 1 # output
2005 Mar 11
3
delay() has been deprecated for 2.1.0
After a bunch of discussion in the core group, we have decided to
deprecate the delay() function (which was introduced as "experimental"
in R 0.50). This is the function that duplicates in R code the
delayed evaluation mechanism (the promise) that's used in evaluating
function arguments.
The problem with delay() was that it was handled inconsistently (e.g.
sometimes you would see
2013 Nov 16
2
serialization for external pointers
Hello,
Are there any recipe to handle serialization / deserialization of
external pointers.
I'm thinking about something similar in spirit to the way we handle
finalization of external pointers.
Currently, if we create an external pointer, save the session, quit R,
then load the session, we get a null pointer.
One way I'm thinking of is to have an environment in the
2011 Jan 13
2
Method dispatch for function call operator?
Dear R gurus,
I am trying to create a nicer API interface for some R modules I have
written. Here, I heavily rely on S3 method dispatch mechanics and
makeActiveBinding() function
I have discovered that I apparently can't dispatch on function call
operator (). While .Primitive("(") exists, which leads me to believe that
things like x(...) are internally translated to
2008 Oct 10
2
Fatal error: unable to restore saved data in .RData
Hello,
I am unable to start an R session by double-clicking on an existing
.RData file from the Windoze file explorer.
A dialogue appears with the message
"Fatal error: unable to restore saved data in .RData",
and I notice in the R Console the last few lines are:
"Loading required package: R2HTML
NULL
error in function () : unused argument(s) (1:43)"
I tried starting
2004 Mar 12
1
Re: [R] No traceback available when using try(...) (PR#6669)
On Fri, 12 Mar 2004 11:44:14 -0500, "Roger D. Peng" <rpeng@jhsph.edu>
wrote :
>Funny, it works for me on R-patched
>
> > f <- function(a) { return(log(a)) }
> > f("A")
>Error in log(x) : Non-numeric argument to mathematical function
> > traceback()
>2: log(a)
>1: f("A")
> > try(f("A"))
>Error in log(x) :
2020 Jun 15
2
numericDeriv alters result of eval in R 4.0.1
Dear R developers,
I've run into a weird behavior of the numericDeriv function (from the stats
package) which I also posted on StackOverflow (question has same title as
this email, except for the version of R).
Running the code bellow we can see that the numericDeriv function gives an
error as the derivative of x^a wrt a is x^a * log(x) and log is not defined
for negative numbers. However,
2020 Jun 16
1
[External] numericDeriv alters result of eval in R 4.0.1
Dear all
As far as I could trace, looking at the function C function numeric_deriv,
this unwanted behavior comes from the inner most loop in, at the very end
of the function,
for(i = 0, start = 0; i < LENGTH(theta); i++) {
for(j = 0; j < LENGTH(VECTOR_ELT(pars, i)); j++, start += LENGTH(ans)) {
SEXP ans_del;
double origPar, xx, delta;
origPar = REAL(VECTOR_ELT(pars, i))[j];
2011 Apr 06
0
Activating a Regular Binding
Greeting R-devel,
I find myself wanting to attach an active binding to an existing
object in the global environment (R 2.12.2), but there doesn't seem to
be an easy way to do this:
> x = 5
> makeActiveBinding("x", function(d) "hi", .GlobalEnv)
Error in makeActiveBinding("x", function(d) "hi", .GlobalEnv) :
symbol already has a regular binding
2008 Oct 03
1
Attributes of top level environments clobbered (was Re: [R] possible bug in function 'var' in R 2.7.2?)
On Fri, Oct 3, 2008 at 3:23 AM, Martin Maechler
<maechler at stat.math.ethz.ch> wrote:
> a much better (and much less error-prone) idea would be to install
> R 2.8.0 alpha even now.
> It will become 'beta' early next week.
>
> We are asking the R community to please install and use
> pre-release versions of R (if you can / are allowed to)
> at least from beta
2016 Apr 20
1
locked environments
Shouldn't the following 4 ways to alter an object in a locked environment
either all work or all fail? (All working would be nice, I think.)
E <- new.env()
assign("var", c(1,2,3,4), envir=E)
lockEnvironment(E, bindings=FALSE)
E$var[1] <- 101 ; E$var
#[1] 101 2 3
local(var[2] <- 102, envir=E)
#Error in eval(expr, envir, enclos) :
# cannot add
2009 Jun 29
1
active bindings and ls.str
Hello,
Should active binding appear as such in ls.str.
> makeActiveBinding( "xx", function(arg){ Sys.sleep(10) }, .GlobalEnv )
> ls.str() # takes 10 seconds
xx : NULL
What we see here is the result of the "setter" of the binding.
I'm attaching a patch that prints this instead:
> ls.str()
xx : <active binding>
Although a better behaviour would be to
2004 Nov 23
3
str() resets class for environments
I noticed the following today --- str() seems to remove any extra
class information added to an environment.
> e <- new.env()
> class(e)
[1] "environment"
> class(e) <- c("foo", class(e))
> class(e)
[1] "foo" "environment"
> str(e)
Classes 'foo', 'environment' length 0 <environment>
> class(e)
[1]
2009 Aug 01
2
Variable alias
Hi Everyone,
is there the possibility in R to assign a variable to be an alias of
another one?
Example:
x <- 17
# assign y to be an alias of x
y # returns 17
x <- 4
y # returns 4
Daniel
2007 Mar 28
1
checking existence of active bindings
Is there any way to check whether an active binding exists without
actually calling the active binding? I'd like to be able to do
something like exists("x", ...) and know whether "x" exists without
actually fetching its value if it is an active binding (because it could
consume significant resources to fetch the value).
The documentation for exists() doesn't