similar to: delayedAssign changing values

Displaying 20 results from an estimated 9000 matches similar to: "delayedAssign changing values"

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
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
2012 Apr 29
1
A doubt about substitute() after delayedAssign()
Hello, ?delayedAssign presents substitute() as a way to look at the expression in the promise. However, msg <- "old" delayedAssign("x", msg) msg <- "new!" x #- new! substitute(x) #- x (was 'msg' ?) Here, we just got 'x'... shouldn't we got 'msg'? Same result when the promise is not evaluated yet: delayedAssign("x",
2005 Jan 24
6
Very Long Expressions
Greetings, I'm having some difficulties with evaluating very long expressions (Windows/Linux 2.0.1), as seen below, and would greatly appreciate any help, thoughts or work arounds. Let's say that I wanted to see what I would get if I added 1 to itself 498 times. One way of doing this would be to evaluate the expression 1+1+1+... > eval(parse(text = paste(rep(1, 498), collapse =
2007 Sep 19
3
delayedAssign
The last two lines of example(delayedAssign) give this: > e <- (function(x, y = 1, z) environment())(1+2, "y", {cat(" HO! "); pi+2}) > (le <- as.list(e)) # evaluates the promises $x <promise: 0x032b31f8> $y <promise: 0x032b3230> $z <promise: 0x032b3268> which contrary to the comment appears unevaluated. Is the comment wrong or is it supposed to
2005 Jan 12
2
?"=" (Windows) (PR#7504)
?"=", ?"==", ?"!=", ?">=", and ?"<=" sends me to the documentation for ?help on Windows, while returning the correct documentation on Linux. Robert > version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor
2006 May 19
2
delayedAssign and interrupts
I noticed something recently that I thought was odd: delayedAssign("x", { Sys.sleep(5); 1 }) x ## Hit Ctrl-C within the first second or 2 gives me: > delayedAssign("x", { Sys.sleep(5); 1 }) > x ## Hit Ctrl-C within the first second or two > x Error: recursive default argument reference > My only problem here is that now I'm stuck---there's no way
2007 Feb 13
1
question on docs for delayedAssign and substitute
The help files for delayedAssign and substitute both say that substitute() can be used to see the expression associated with a promise. However, I can't see how to do that. When I try the example in help file for delayedAssign I don't see substitute() extracting the promise, e.g.: > msg <- "old" > delayedAssign("x", msg) > msg <-
2008 Apr 28
2
time zone conversion
Hello, I'm trying to convert times in the EST/EDT (New York) format to times in the GMT/BST (London) and UTC+9 format (Tokyo). That is, if I know what time it is in New York, what is local time in London and Tokyo? Ex: Here's the conversion from New York EST/EDT time to London's GMT/BST time zone for three days in 2007. Note that the US and London change to daylight savings on
2006 May 22
3
Wishlist: Vignettes on CRAN
I was recently browsing through CRAN's Finance task view to remind myself of the publicly available packages relevant to my work. As the reference manuals are all online, I am able to flip through the available functions to get an idea of the package's scope before downloading. That said, many authors have taken the time to additionally provide a useful vignette which provides a better
2005 Jan 27
3
Indexing Lists and Partial Matching
I was unaware until recently that partial matching was used to index data frames and lists. This is now causing a great deal of problems in my code as I sometimes index a list without knowing what elements it contains, expecting a NULL if the column does not exist. However, if partial matching is used, sometimes R will return an object I do not want. My question, is there an easy way of getting
2005 Feb 28
2
Changing function arguments to NULL
I'm trying to build a recursive set of functions that take a set of arguments, change some of the arguments and recursively call the same (or different) function. For example here's a stupid recursive counting function that prints back all integers from x to 0 (and ignores arguments y and z) cnt <- function(x, y, z) { stopifnot(is.numeric(x)) print (x) recursionFUN <-
2012 Jan 30
4
replacing characters in matrix. substitute, delayedAssign, huh?
A user question today has me stumped. Can you advise me, please? User wants a matrix that has some numbers, some variables, possibly even some function names. So that has to be a character matrix. Consider: > BM <- matrix("0.1", 5, 5) Use data.entry(BM) or similar to set some to more abstract values. > BM[3,1] <- "a" > BM[4,2] <- "b" >
2006 Nov 29
1
Removing terms from formula
R-help, Given a simple linear model, say lm(x ~ y + z), I would like to remove model terms that are factors with only one level. Thus, if 'z' were a factor with only one level, lm(x ~ y + z) becomes lm(x ~ y + 1). Likewise, if both 'y' and 'z' are one-level factors, then the resulting calculation is simply lm(x ~ 1). Unfortunately, I have not been able to come up with an
2010 Jun 29
2
POSIXlt matching bug
I came across the below mis-feature/bug using match with POSIXlt objects (from strptime) in R 2.11.1 (though this appears to be an old issue). > x <- as.POSIXlt(Sys.Date()) > table <- as.POSIXlt(Sys.Date()+0:5) > length(x) [1] 1 > x %in% table # I expect TRUE [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE > match(x, table) # I expect 1 [1] NA NA NA NA NA NA NA NA
2006 Oct 23
4
Changing function arguments
R-Developers, I'm looking for some help computing on the R language. I'm hoping to write a function that parses a language or expression object and returns another expression with all instances of certain argument of a given function altered. For instance, say I would like my function, myFun to take an expression and whenever the argument 'x' appears within the function FUN inside
2010 Jul 06
1
with(x, Recall()) Crash
R-devel, I discovered a segfault in my R code that boiled down to my incorrect use of the Recall() function embedded within a with() function. Since segfaults are generally bad things, even when it's the user's fault for writing nonsense code, I thought I'd pass along the offending code. I've tested the crash on R 2.11.1 (on Linux and Mac), but not in devel versions of R. HTH,
2008 Jul 08
1
split.Date
Hello, I wanted to suggest that the below method for split.Date be added to the base library to significantly speed up splits with values of class Date. In the below example I show a speed improvement of 175x for 1000 data points. On a vector of size 1e6, the time difference was 22 minutes for split.default versus 0.3 seconds for the split.Date function below (!). Note that this improvement will
2005 Jan 05
2
Rcmd check Error help
R-help, I'm the primary developer for an increasingly large R package with over three thousand lines of code. Unfortunately, do the complexity of the code, I sometimes am required to change several interoperating parts of the package before testing for bugs and performance. And sometimes unnoticed syntax errors slip in that cause Rcmd check / INSTALL to fail with such messages as: Error in
2005 Jan 07
1
Creating unary operators
Is it correct (by its lack of mention in the R-Language Definition Manual) that it is impossible to create a user-defined unary operator? Ex: (This doesn't work, but it's an example of what I'm looking for) > "%PLUSONE%" <- function(x) x + 1 > %PLUSONE% 2 [1] 3 And if the above is impossible, am I limited to only the + - ~ ! unary operators for overloading? On