similar to: Error "promise already under evaluation ..." with function(x, dim=dim(x))

Displaying 20 results from an estimated 90000 matches similar to: "Error "promise already under evaluation ..." with function(x, dim=dim(x))"

2014 Nov 24
1
Error "promise already under evaluation ..." with function(x, dim=dim(x))
On Sat, Nov 15, 2014 at 1:47 AM, Duncan Murdoch <murdoch.duncan at gmail.com> wrote: > > On 14/11/2014, 9:06 PM, Henrik Bengtsson wrote: > > I've meant to ask the following for several years now. I understand why: > > > >> foo <- function(x, dim=dim) { dim } > >> foo(1) > > Error in foo(1) : > > promise already under evaluation:
2014 Nov 24
0
Error "promise already under evaluation ..."
> The above question still stands, but otherwise, I overlooked the most > obvious solution: > > dim_1 <- function(x) dim(x) > > Unit: nanoseconds > expr min lq mean median uq max neval cld > dim(x) 0 1 72.941 1 1 2696 1000 a > base::dim(x) 11549 13474 15105.950 14245 15399 60824
2006 Oct 18
1
Error condition in evaluating a promise
Is there a way to raise an error condition when a promise is evaluated such that is can be evaluated again? Right now strange things happen when the evaluation fails: > delayedAssign("x", if (failed) stop("you have to initialize me first!") else foo) > foo <- "I'm foo" > failed<-TRUE > x Error: you have to initialize me first! > x
2023 Oct 31
1
dim<-() changed in R-devel; no longer removing "dimnames" when doing dim(x) <- dim(x)
Hi Martin, Henrik, I actually like this change. Makes a lot of sense IMO that dim(x) <- dim(x) be a no-op, or, more generally, that foo(x) <- foo(x) be a no-op for any setter/getter combo. FWIW S4Arrays::set_dim() does that too. It also preserves the dimnames if the right value is only adding or dropping outermost (ineffective) dimensions: ??? > x <- array(1:6, dim=c(2,3,1),
2010 Apr 29
3
dump not evaluating promises?
I'm using the dump command to pass data to WinBUGS/OpenBUGS/JAGS and have run into a problem. Here is some R-code: foo <- array(1:6, dim=c(2,3)) dump('foo', file='dumpdata.R') dump('foo', file='dumpdata.R', append=TRUE, evaluate=TRUE) foo2 <- array(c(2,3,5,7,9,7,5,3), dim=c(2,4)) dump('foo2', file='dumpdata.R', append=TRUE) And here is
2023 Oct 30
2
dim<-() changed in R-devel; no longer removing "dimnames" when doing dim(x) <- dim(x)
>>>>> Henrik Bengtsson >>>>> on Sun, 29 Oct 2023 10:42:19 -0700 writes: > Hello, > the fix of PR18612 > (https://bugs.r-project.org/show_bug.cgi?id=18612) in > r85380 > (https://github.com/wch/r-source/commit/2653cc6203fce4c48874111c75bbccac3ac4e803) > caused a change in `dim<-()`. Specifically, in the past,
2023 Oct 29
1
dim<-() changed in R-devel; no longer removing "dimnames" when doing dim(x) <- dim(x)
Hello, the fix of PR18612 (https://bugs.r-project.org/show_bug.cgi?id=18612) in r85380 (https://github.com/wch/r-source/commit/2653cc6203fce4c48874111c75bbccac3ac4e803) caused a change in `dim<-()`. Specifically, in the past, any `dim<-()` assignment would _always_ remove "dimnames" and "names" attributes per help("dim"): The replacement method changes
2009 May 29
1
edge case concerning NA in dim() (PR#13729)
Full_Name: Allan Stokes Version: 28.1 OS: XP Submission from: (NULL) (24.108.0.245) I'm trying to use package HDF5 and have discovered some round-trip errors: save, load, save is not idempotent. I started digging into the type system to figure out what type graffiti is fouling this up. Soon I discovered that comparisons with NULL produce zero length vectors, which I hadn't known was
2013 May 15
1
Substitute unaware when promise objects are evaluated
R-devel, I used the 'substitute' function to create labels for objects inside an environment, without actually evaluating the objects, as the objects might be promises. However, I was surprised to see that 'substitute' returns the expression slot of the original promise even after the promise has been forcibly evaluated. (Doesn't the promise go away after evaluation?) This
2014 Feb 11
1
getting environment from "top" promise
Hi all, It seems that there is a use case for obtaining the environment for the "top" promise. By "top", I mean following the promise chain up the call stack until hitting a non-promise. S4 data containers often mimic the API of base R data structures. This means writing S4 methods for functions that quote their arguments, like with() and subset(). The methods package
2013 May 16
3
Substitute / delayedAssign (was: Substitute unaware when promise objects are evaluated)
Duncan, Thank you for the clarification on how delayedAssign works. Should R-level interfaces to promise objects ever become available, I expect they would at time come in handy. On the subject of substitute and delayedAssign, I do have a follow-up question for the list. I'm trying to convert a named list of expression objects into an environment of promise objects. After conversion, each
2009 Jan 12
1
x <- 1:2; dim(x) <- 2? A vector or not?
Ran into the follow intermediate case in an external package (w/ recent R v2.8.1 patched and R v2.9.0 devel): > x <- 1:2 > dim(x) <- 2 > dim(x) [1] 2 > x [1] 1 2 > str(x) int [, 1:2] 1 2 > nrow(x) [1] 2 > ncol(x) [1] NA > is.vector(x) [1] FALSE > is.matrix(x) [1] FALSE > is.array(x) [1] TRUE > x[1] [1] 1 > x[,1] Error in x[, 1] : incorrect number of
2015 Jan 26
2
Inspect a "delayed" assigned whose value throws an error?
Hi, I got an interesting programming challenge: How do you inspect an object which is assigned via delayedAssign() and that throws an error as soon as it is "touched" (=the value is evaluated)? Is it possible? MINIMAL EXAMPLE: $ R --vanilla > delayedAssign("foo", stop("Hey!")) (If you find this minimal example silly/obvious, please skip down to the real
2000 Jun 30
1
dim(a <- ...) sets invisible flag erronously (PR#587)
{Nothing really harmful; R 1.1.0} dim(.) sets (or doesn't clear) the ``invisible flag'' for printing in certain circumstances: > dim(a <- cbind(1)) > does *not* print as it should : > dim(a) [1] 1 1 --- Question to the real "hackers" : How can I check this using R code alone (not using files), i.e. (how) can I ask an R expression if its
2009 Jan 25
1
[Fwd: Re: evaluation question]
dear list, below is an edited version of my response to an r user asking me for explaining some issues related to r's evaluation rules. i find the problem interesting enough to be forwarded to the list, hopefully for comments from whoever may want to extend or correct my explanations. (i'd like to add that much as i'm happy to receive and answer offline mails, questions related to r
2007 Sep 12
2
Evaluating args in a function
Can anyone explain what I'm doing wrong here: > fred <- data.frame() > class(fred) [1] "data.frame" > test.fn <- function(x,class=class(x)) {class} > test.fn(fred) Error in test.fn(fred) : promise already under evaluation: recursive default argument reference or earlier problems? R 2.5.1 on both Windows and SUSE Linux. -- Sanford Weisberg, sandy at
2018 May 03
1
The stages of standard function evaluation
Dear R Help folks -- I have been trying to put together a list of the steps or stages of R function evaluation, with particular focus on those that have "standard" or "nonstandard" forms. This is both for my own edification and also because I am thinking of joining the world of R bloggers and have been trying to put together some draft posting that might be useful. I seem to
2007 Sep 24
1
Inspecting promises
Is there some way of displaying the expression and evaluation environment associated with a promise? I have found the following: > # first run these two commands to set up example > e <- new.env() > delayedAssign("y", x*x, assign.env = e) > # method 1. shows expression but not evaluation environment > str(as.list(e)) List of 1 $ y: promise to language x * x >
2010 Feb 11
1
Fwd: Recall function: "evaluation nested too deeply: infinite recursion / options(expressions=)?"
hello all i searched the archives and couldn't get a solution to the following question. i have the following function: F=function(z,v) { if (v==-.5) return(1) else return(2*v/z + 1/Recall(z,v-1)) } and while testing whether it works (ie F(z,v) is approx = besselK(z,1+v)/besselK(z,V). the recursion formula allows one to calculate besselK(z,1+v)/besselK(z,V) for large values of z )
2003 Aug 11
1
An inconsistency with promise in attributes
When an attribute is a delayed expression sometimes it is not forced when it is extracted. > x <- list() > attr(x, "p") <- delay(1) > x list() attr(,"p") <promise: 0x11e4bb8> > val <- attr(x, "p") > val [1] 1 > attr(x, "p") <promise: 0x11e4bb8> I am not quite sure whether the above is a bug or not but I think