search for: makeactivebinding

Displaying 20 results from an estimated 28 matches for "makeactivebinding".

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 does not require me to enter a pair of parentheses to execute it. This worked just fine so far as the command goes...
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:...
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 "set" print(i) # output [1] 1 # Surprising behavior starts here: for(i in 2:3) print(i) # output [1] "set"...
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 th...
2013 Nov 16
2
serialization for external pointers
...zation - lose their active ness when reloaded: $ R [...] > f <- local( { + x <- 1 + function(v) { + if (missing(v)) + cat("get\n") + else { + cat("set\n") + x <<- v + } + x + } + }) > makeActiveBinding("fred", f, .GlobalEnv) > bindingIsActive("fred", .GlobalEnv) [1] TRUE > > q("yes") get get romain at naxos /tmp $ R [..] > fred [1] 1 > bindingIsActive("fred", .GlobalEnv) [1] FALSE Is this possible ? Is there any other hook to handle s...
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 Now I can get around this with some fancy assignment, but this seems ugly and underhanded: > x = 5 > y = x > r...
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 .Primitive("(")(x, ...), I can't seem to do something like: x <...
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
2009 Mar 16
1
Using and 'eval' and environments with active bindings
The following code produces an error in current R-devel f <- function(value) { if(!missing(value)) 100 else 2 } e <- new.env() makeActiveBinding("x", f, e) eval(substitute(list(x)), e) The error, after calling 'eval' is Error in eval(expr, envir, enclos) : element 1 is empty; the part of the args list of 'list' being evaluated was: (x) It has something to do with the change in R_isMissing in revision r4...
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" "package:datasets" "package:utils" [7] "packa...
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
2020 May 23
0
Surpising behavior when using an active binding as loop index in R 4.0.0
Possibly just a symptom of the earlier behavior, but I'll amend my example, below, with an even more disturbing observation: Am Sat, 23 May 2020 13:19:24 +0200 schrieb Thomas Friedrichsmeier via R-devel <r-devel at r-project.org>: [...] > Consider the code below: > > makeActiveBinding("i", > function(value) { > if (missing(value)) { > x > } else { > print("set") > x <<- value > } > }, globalenv()) > > i <- 1 # output "set" > print(i) # output [1] 1 > > # Surprising behavior starts...
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 be...
2011 Apr 05
1
Names of a data set in a package
For some reason I want to let one data set in a package be known under two different names. Is that possible, and if so, how? I do not want to have two copies of the data set in the package. Thanks, G?ran -- G?ran Brostr?m Department of Statistics Ume? University SE-90187 Ume?, Sweden
2012 Feb 10
2
the value of the last expression
Is there an analogue of common lisp "*" variable which contains the value of the last expression? E.g., in lisp: > (+ 1 2) 3 > * 3 I wish I could recover the value of the last expression without re-evaluating it. thanks -- Sam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X 11.0.11004000 http://www.childpsy.net/ http://camera.org http://ffii.org
2007 Mar 28
1
checking existence of active bindings
...in the active binding being called: > fx <- function(v) { + if (missing(v)) + cat("getting x1\n") + else { + cat("setting x1\n") + assign("x1", v, envir=globalenv()) + } + get("x1", envir=globalenv()) + } > makeActiveBinding("x", fx, globalenv()) NULL > x1 <- 3 > x getting x1 [1] 3 > exists("x", inherits=FALSE) getting x1 [1] TRUE > sessionInfo() R version 2.4.1 (2006-12-18) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONE...
2012 Jan 18
5
Executable expressions
Given a<-"c(1,2,3,4,5)" How can  I evaluate the variable a to return a (numeric) vector comprising of 1,2,3,4,5? Thanks. [[alternative HTML version deleted]]
2011 Sep 08
3
Can't load workspaces
I've seen a number of issues with the loading of workspaces discussed previously, but here's another one... I simply can't load any saved workspace at all... Here's an example, starting with an empty workspace and creating a single variable "a". > a<-1:5 > save.image("a.Rdata") > rm(a) > load("a.Rdata") Error in function ()  : unused
2010 Nov 17
2
Reference classes: accessor functions via 'getRefClass(...)$accessors(...)'
Hi there, I''d like to choose between an "static" and "dynamic" access of a reference class field, say ''a''. myObj <- getRefClass("Blabla")$new() Static: myObj$a Dynamic: myObj$a.get() where the function retrieves the data from a database (or some other location), stores it to a buffer and
2008 Jul 07
2
A shorter version of ".Last.value"?
Hi, There is an object, ".Last.value" to which the result of the most recent evaluation is assigned. This is similar to "ans" in Matlab. In Matlab "ans" can be very useful and time-saving, but typing the larger R version is somewhat clunky and takes away from the usefulness. Is it possible to reassign '.Last.value' to something simpler, like