[Rd] add .emacs.desktop and .emacs.desktop.lock to files ignored by R CMD build?
Is it possible to consider adding .emacs.desktop and .emacs.desktop.lock to files ignored by R CMD build? Thanks, Georgi -- Dr Georgi Boshnakov tel: (+44) (0)161 306 3684 School of Mathematics fax: (+44) (0)161 306 3669 Alan Turing Building 1.125 The University of Manchester email: georgi.boshna...@manchester.ac.uk Oxford Road Manchester M13 9PL UK __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] add .emacs.desktop and .emacs.desktop.lock to files ignored by R CMD build?
On 15 July 2015 at 11:44, Georgi Boshnakov wrote: | Is it possible to consider adding .emacs.desktop and .emacs.desktop.lock to files ignored by R CMD build? You do that at your end via a file .Rbuildignore. From Section 1.3.2 of WRE: To exclude files from being put into the package, one can specify a list of exclude patterns in file '.Rbuildignore' in the top-level source directory. These patterns should be Perl-like regular expressions (see the help for 'regexp' in R for the precise details), one per line, to be matched case-insensitively(1) against the file and directory names relative to the top-level package source directory. In addition, directories from source control systems(2) or from 'eclipse'(3), directories with names ending '.Rcheck' or 'Old' or 'old' and files 'GNUMakefile'(4), 'Read-and-delete-me' or with base names starting with '.#', or starting and ending with '#', or ending in '~', '.bak' or '.swp', are excluded by default. In addition, those files in the 'R', 'demo' and 'man' directories which are flagged by 'R CMD check' as having invalid names will be excluded. Also, this would have been a splendid question for the new mailing r-package-devel: https://stat.ethz.ch/mailman/listinfo/r-package-devel Hth, Dirk -- http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Two bugs showing up mostly on SPARC systems
On 14/07/2015 9:29 PM, Radford Neal wrote: > On Tue, Jul 14, 2015 at 07:52:56PM -0400, Duncan Murdoch wrote: >> On 14/07/2015 6:08 PM, Radford Neal wrote: >>> In testing pqR on Solaris SPARC systems, I have found two bugs that >>> are also present in recent R Core versions. You can see the bugs and >>> fixes at the following URLs: >>> >>> >>> https://github.com/radfordneal/pqR/commit/739a4960a4d8f3a3b20cfc311518369576689f37 >> >> Thanks for the report. Just one followup on this one: >> >> There are two sections of code that are really similar. Your patch >> applies to the code in port_nlsb(), but there's a very similar test in >> port_nlminb(), which is called from nlminb() in R. Do you think it >> would be a good idea to apply the same patch there as well? It doesn't >> look like it would hurt, but I don't know this code at all, so it might >> be unnecessary. > > Looking at nlminb, it seems that this bug doesn't exist there. The > R code sets low <- upp <- NULL, as in nls, but later there is an > "else low <- upp <- numeric()" that ensures that low and upp are never > actually NULL. This may have been a fix for the bug showing up in > nlminb that was not applied to nls as well (and of course, the fix > didn't delete the now pointless low <- upp <- NULL). > > The nlminb code might be a better fix, stylistically, after removing > "low <- upp <- NULL", though it seems that both it and my fix for nls > should work. Of course, both assume that the call of the C function > is done only from this R code, so no other types for low and upp are > possible. And really the whole thing ought to be rewritten, since the > .Call functions modify variables without any regard for whether or not > their values are shared. Thanks. I think I'll make the mods to the R code rather than the C code, to make the two functions more consistent, and so as not to suggest that port.c is actually okay. The modification of variables without checking for sharing is definitely something that should be fixed. It looks to me as though we're likely to get away with it here (both m and iv are allocated by functions called by nls(), not by the user), but it's still really bad practice. Duncan Murdoch __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] bquote/evalq behavior changed in R-3.2.1
Hello, I upgraded from 3.1.2 to 3.2.1 and am receiving errors on code that worked as I intended previously. Briefly, I am using bquote to generate expressions to modify data.table objects within a function, so I need the changes to actually be stored in the given environment. Previously, I used code like the following: test <- list(bquote(x <- 10)) fenv <- environment() rapply(test, evalq, envir = fenv) Although the code in the example above is much simpler, it shows the problem. On 3.1.2 the expression is evaluated and x is stored as 10 in the given environment, fenv. In 3.2.1 the code throws an error: Error in eval(substitute(expr), envir, enclos) : object 'X' not found I could not find anything in the release notes that would explain this change. Changing evalq to eval works in 3.2.1, but eval does not store x in the given environment in 3.1.2. Thanks, Dayne [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] bquote/evalq behavior changed in R-3.2.1
On 15/07/2015 2:49 PM, Dayne Filer wrote: > Hello, > > I upgraded from 3.1.2 to 3.2.1 and am receiving errors on code that worked > as I intended previously. Briefly, I am using bquote to generate > expressions to modify data.table objects within a function, so I need the > changes to actually be stored in the given environment. Previously, I used > code like the following: > > test <- list(bquote(x <- 10)) > fenv <- environment() > rapply(test, evalq, envir = fenv) > > Although the code in the example above is much simpler, it shows the > problem. On 3.1.2 the expression is evaluated and x is stored as 10 in the > given environment, fenv. In 3.2.1 the code throws an error: > > Error in eval(substitute(expr), envir, enclos) : object 'X' not found > > I could not find anything in the release notes that would explain this > change. Changing evalq to eval works in 3.2.1, but eval does not store x in > the given environment in 3.1.2. Please submit this as a bug report (at bugs.r-project.org). I don't know for sure that it's a bug, but it looks like one: there's no 'X' in your code, so that message is coming from something internal. It would be helpful to include results that work from 3.1.2 as well as what you're seeing in 3.2.1. I'm still seeing the error you reported in R-devel, so I think the bug is still there... Duncan Murdoch __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] bquote/evalq behavior changed in R-3.2.1
I am curious why you used evalq instead of eval in this code. Bill Dunlap TIBCO Software wdunlap tibco.com On Wed, Jul 15, 2015 at 11:49 AM, Dayne Filer wrote: > Hello, > > I upgraded from 3.1.2 to 3.2.1 and am receiving errors on code that worked > as I intended previously. Briefly, I am using bquote to generate > expressions to modify data.table objects within a function, so I need the > changes to actually be stored in the given environment. Previously, I used > code like the following: > > test <- list(bquote(x <- 10)) > fenv <- environment() > rapply(test, evalq, envir = fenv) > > Although the code in the example above is much simpler, it shows the > problem. On 3.1.2 the expression is evaluated and x is stored as 10 in the > given environment, fenv. In 3.2.1 the code throws an error: > > Error in eval(substitute(expr), envir, enclos) : object 'X' not found > > I could not find anything in the release notes that would explain this > change. Changing evalq to eval works in 3.2.1, but eval does not store x in > the given environment in 3.1.2. > > Thanks, > > Dayne > > [[alternative HTML version deleted]] > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] bquote/evalq behavior changed in R-3.2.1
In 3.1.2 eval does not store the result of the bquote-generated call in the given environment. Interestingly, in 3.2.1 eval does store the result of the bquote-generated call in the given environment. In other words if I run the given example with eval rather than evalq, on 3.1.2 "x" is never stored in "fenv," but it is when I run the same code on 3.2.1. However, the given example stores "x" in "fenv" on 3.1.2, but throws the error I gave when run on 3.2.1. To give credit, I received the idea for using evalq from SO: http://stackoverflow.com/a/22559385 Dayne On Wed, Jul 15, 2015 at 3:29 PM, William Dunlap wrote: > I am curious why you used evalq instead of eval in this code. > > Bill Dunlap > TIBCO Software > wdunlap tibco.com > > On Wed, Jul 15, 2015 at 11:49 AM, Dayne Filer > wrote: > >> Hello, >> >> I upgraded from 3.1.2 to 3.2.1 and am receiving errors on code that worked >> as I intended previously. Briefly, I am using bquote to generate >> expressions to modify data.table objects within a function, so I need the >> changes to actually be stored in the given environment. Previously, I used >> code like the following: >> >> test <- list(bquote(x <- 10)) >> fenv <- environment() >> rapply(test, evalq, envir = fenv) >> >> Although the code in the example above is much simpler, it shows the >> problem. On 3.1.2 the expression is evaluated and x is stored as 10 in the >> given environment, fenv. In 3.2.1 the code throws an error: >> >> Error in eval(substitute(expr), envir, enclos) : object 'X' not found >> >> I could not find anything in the release notes that would explain this >> change. Changing evalq to eval works in 3.2.1, but eval does not store x >> in >> the given environment in 3.1.2. >> >> Thanks, >> >> Dayne >> >> [[alternative HTML version deleted]] >> >> __ >> R-devel@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel >> > > [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] bquote/evalq behavior changed in R-3.2.1
My best guess is that it could be related to this commit: https://github.com/wch/r-source/commit/14f904c32a44010d4dfb8a829805648a88c22f53, since that's the only change that's touched `rapply` lately. On Wed, Jul 15, 2015 at 12:35 PM, Dayne Filer wrote: > In 3.1.2 eval does not store the result of the bquote-generated call in the > given environment. Interestingly, in 3.2.1 eval does store the result of > the bquote-generated call in the given environment. > > In other words if I run the given example with eval rather than evalq, on > 3.1.2 "x" is never stored in "fenv," but it is when I run the same code on > 3.2.1. However, the given example stores "x" in "fenv" on 3.1.2, but throws > the error I gave when run on 3.2.1. > > To give credit, I received the idea for using evalq from SO: > http://stackoverflow.com/a/22559385 > > Dayne > > > On Wed, Jul 15, 2015 at 3:29 PM, William Dunlap wrote: > >> I am curious why you used evalq instead of eval in this code. >> >> Bill Dunlap >> TIBCO Software >> wdunlap tibco.com >> >> On Wed, Jul 15, 2015 at 11:49 AM, Dayne Filer >> wrote: >> >>> Hello, >>> >>> I upgraded from 3.1.2 to 3.2.1 and am receiving errors on code that worked >>> as I intended previously. Briefly, I am using bquote to generate >>> expressions to modify data.table objects within a function, so I need the >>> changes to actually be stored in the given environment. Previously, I used >>> code like the following: >>> >>> test <- list(bquote(x <- 10)) >>> fenv <- environment() >>> rapply(test, evalq, envir = fenv) >>> >>> Although the code in the example above is much simpler, it shows the >>> problem. On 3.1.2 the expression is evaluated and x is stored as 10 in the >>> given environment, fenv. In 3.2.1 the code throws an error: >>> >>> Error in eval(substitute(expr), envir, enclos) : object 'X' not found >>> >>> I could not find anything in the release notes that would explain this >>> change. Changing evalq to eval works in 3.2.1, but eval does not store x >>> in >>> the given environment in 3.1.2. >>> >>> Thanks, >>> >>> Dayne >>> >>> [[alternative HTML version deleted]] >>> >>> __ >>> R-devel@r-project.org mailing list >>> https://stat.ethz.ch/mailman/listinfo/r-devel >>> >> >> > > [[alternative HTML version deleted]] > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Two bugs showing up mostly on SPARC systems
On 14/07/2015 6:08 PM, Radford Neal wrote: > In testing pqR on Solaris SPARC systems, I have found two bugs that > are also present in recent R Core versions. You can see the bugs and > fixes at the following URLs: > > > https://github.com/radfordneal/pqR/commit/739a4960a4d8f3a3b20cfc311518369576689f37 > > > https://github.com/radfordneal/pqR/commit/339b7286c7b43dcc6b00e51515772f1d7dce7858 > > The first bug, in nls, is most likely to occur on a 64-bit big-endian > system, but will occur with low probability on most platforms. > > The second bug, in readBin, may occur on systems in which unaligned > access to data more than one byte in size is an error, depending on > details of the compiler. It showed up with gcc 4.9.2 on a SPARC > system. The fix slightly changes the error behaviuor, signaling an > error on inappropriate reads before reading any data, rather than > after reading one (but not all) items as before. I've now taken a look at the second bug. It's a little harder to apply your patch, since your code is based on an old version of R; current R has more error checking and allows long vector results from this function. But it's basically just a matter of being careful not to make changes to the newer code. So this one should go into R-patched more or less as-is. Duncan Murdoch __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] bquote/evalq behavior changed in R-3.2.1
I think rapply() was changed to act like lapply() in this respect. In R-3.1.3 we got rapply(list(quote(1+myNumber)), evalq, envir=list2env(list(myNumber=17))) #[1] 18 rapply(list(quote(1+myNumber)), eval, envir=list2env(list(myNumber=17))) #Error in (function (expr, envir = parent.frame(), enclos = if (is.list(envir) || : object 'myNumber' not found lapply(list(quote(1+myNumber)), evalq, envir=list2env(list(myNumber=17))) #Error in eval(substitute(expr), envir, enclos) : object 'X' not found lapply(list(quote(1+myNumber)), eval, envir=list2env(list(myNumber=17))) #[[1]] #[1] 18 while in R-3.2.0 we get rapply(list(quote(1+myNumber)), evalq, envir=list2env(list(myNumber=17))) #Error in eval(substitute(expr), envir, enclos) : object 'X' not found rapply(list(quote(1+myNumber)), eval, envir=list2env(list(myNumber=17))) #[1] 18 lapply(list(quote(1+myNumber)), evalq, envir=list2env(list(myNumber=17))) #Error in eval(substitute(expr), envir, enclos) : object 'X' not found lapply(list(quote(1+myNumber)), eval, envir=list2env(list(myNumber=17))) #[[1]] #[1] 18 Make the FUN argument function(arg)sys.call() to see some details of the change. Bill Dunlap TIBCO Software wdunlap tibco.com On Wed, Jul 15, 2015 at 12:35 PM, Dayne Filer wrote: > In 3.1.2 eval does not store the result of the bquote-generated call in > the given environment. Interestingly, in 3.2.1 eval does store the result > of the bquote-generated call in the given environment. > > In other words if I run the given example with eval rather than evalq, on > 3.1.2 "x" is never stored in "fenv," but it is when I run the same code on > 3.2.1. However, the given example stores "x" in "fenv" on 3.1.2, but throws > the error I gave when run on 3.2.1. > > To give credit, I received the idea for using evalq from SO: > http://stackoverflow.com/a/22559385 > > Dayne > > > On Wed, Jul 15, 2015 at 3:29 PM, William Dunlap wrote: > >> I am curious why you used evalq instead of eval in this code. >> >> Bill Dunlap >> TIBCO Software >> wdunlap tibco.com >> >> On Wed, Jul 15, 2015 at 11:49 AM, Dayne Filer >> wrote: >> >>> Hello, >>> >>> I upgraded from 3.1.2 to 3.2.1 and am receiving errors on code that >>> worked >>> as I intended previously. Briefly, I am using bquote to generate >>> expressions to modify data.table objects within a function, so I need >>> the >>> changes to actually be stored in the given environment. Previously, I >>> used >>> code like the following: >>> >>> test <- list(bquote(x <- 10)) >>> fenv <- environment() >>> rapply(test, evalq, envir = fenv) >>> >>> Although the code in the example above is much simpler, it shows the >>> problem. On 3.1.2 the expression is evaluated and x is stored as 10 in >>> the >>> given environment, fenv. In 3.2.1 the code throws an error: >>> >>> Error in eval(substitute(expr), envir, enclos) : object 'X' not found >>> >>> I could not find anything in the release notes that would explain this >>> change. Changing evalq to eval works in 3.2.1, but eval does not store x >>> in >>> the given environment in 3.1.2. >>> >>> Thanks, >>> >>> Dayne >>> >>> [[alternative HTML version deleted]] >>> >>> __ >>> R-devel@r-project.org mailing list >>> https://stat.ethz.ch/mailman/listinfo/r-devel >>> >> >> > [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] bquote/evalq behavior changed in R-3.2.1
On Jul 15, 2015, at 12:51 PM, William Dunlap wrote: > I think rapply() was changed to act like lapply() in this respect. > When I looked at the source of the difference, it was that typeof() returned 'language' in 3.2.1, while it returned 'list' in the earlier version of R. The first check in rapply's code in both version was: if (typeof(object) != "list") stop("'object' must be a list") Wrapping list() around the first argument and switching to using eval with an expression-object rather than a call-object seemed to solve the problem when this was posed as a question on StackOverflow, but Dayne was not happy with that solution for other reasons that he is not describing. -- David. > In R-3.1.3 we got > rapply(list(quote(1+myNumber)), evalq, envir=list2env(list(myNumber=17))) > #[1] 18 > rapply(list(quote(1+myNumber)), eval, envir=list2env(list(myNumber=17))) > #Error in (function (expr, envir = parent.frame(), enclos = if > (is.list(envir) || : > object 'myNumber' not found > lapply(list(quote(1+myNumber)), evalq, envir=list2env(list(myNumber=17))) > #Error in eval(substitute(expr), envir, enclos) : object 'X' not found > lapply(list(quote(1+myNumber)), eval, envir=list2env(list(myNumber=17))) > #[[1]] > #[1] 18 > while in R-3.2.0 we get > rapply(list(quote(1+myNumber)), evalq, envir=list2env(list(myNumber=17))) > #Error in eval(substitute(expr), envir, enclos) : object 'X' not found > rapply(list(quote(1+myNumber)), eval, envir=list2env(list(myNumber=17))) > #[1] 18 > lapply(list(quote(1+myNumber)), evalq, envir=list2env(list(myNumber=17))) > #Error in eval(substitute(expr), envir, enclos) : object 'X' not found > lapply(list(quote(1+myNumber)), eval, envir=list2env(list(myNumber=17))) > #[[1]] > #[1] 18 > > Make the FUN argument function(arg)sys.call() to see some details of the > change. > > > Bill Dunlap > TIBCO Software > wdunlap tibco.com > > On Wed, Jul 15, 2015 at 12:35 PM, Dayne Filer wrote: > >> In 3.1.2 eval does not store the result of the bquote-generated call in >> the given environment. Interestingly, in 3.2.1 eval does store the result >> of the bquote-generated call in the given environment. >> >> In other words if I run the given example with eval rather than evalq, on >> 3.1.2 "x" is never stored in "fenv," but it is when I run the same code on >> 3.2.1. However, the given example stores "x" in "fenv" on 3.1.2, but throws >> the error I gave when run on 3.2.1. >> >> To give credit, I received the idea for using evalq from SO: >> http://stackoverflow.com/a/22559385 >> >> Dayne >> >> >> On Wed, Jul 15, 2015 at 3:29 PM, William Dunlap wrote: >> >>> I am curious why you used evalq instead of eval in this code. >>> >>> Bill Dunlap >>> TIBCO Software >>> wdunlap tibco.com >>> >>> On Wed, Jul 15, 2015 at 11:49 AM, Dayne Filer >>> wrote: >>> Hello, I upgraded from 3.1.2 to 3.2.1 and am receiving errors on code that worked as I intended previously. Briefly, I am using bquote to generate expressions to modify data.table objects within a function, so I need the changes to actually be stored in the given environment. Previously, I used code like the following: test <- list(bquote(x <- 10)) fenv <- environment() rapply(test, evalq, envir = fenv) Although the code in the example above is much simpler, it shows the problem. On 3.1.2 the expression is evaluated and x is stored as 10 in the given environment, fenv. In 3.2.1 the code throws an error: Error in eval(substitute(expr), envir, enclos) : object 'X' not found I could not find anything in the release notes that would explain this change. Changing evalq to eval works in 3.2.1, but eval does not store x in the given environment in 3.1.2. Thanks, Dayne [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel >>> >>> >> > > [[alternative HTML version deleted]] > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel David Winsemius Alameda, CA, USA __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] bquote/evalq behavior changed in R-3.2.1
Another aspect of the change is (using TERR's RinR package): > options(REvaluators=list(makeREvaluator("R-3.1.3"), makeREvaluator("R-3.2.0"))) > RCompare(rapply(list(quote(function(x)x),list(quote(pi),quote(7-4))), function(arg)typeof(arg))) R version 3.1.3 (2015-03-09) R version 3.2.0 (2015-04-16) [1,] [1] "closure" "double" [1] "language" "symbol" [2,] [3] "double" [3] "language" $all.equal $all.equal$`R version 3.1.3 (2015-03-09) vs. R version 3.2.0 (2015-04-16)` [1] "3 string mismatches" I prefer the new semantics, but it is a change. Bill Dunlap TIBCO Software wdunlap tibco.com On Wed, Jul 15, 2015 at 1:25 PM, David Winsemius wrote: > > On Jul 15, 2015, at 12:51 PM, William Dunlap wrote: > > > I think rapply() was changed to act like lapply() in this respect. > > > > When I looked at the source of the difference, it was that typeof() > returned 'language' in 3.2.1, while it returned 'list' in the earlier > version of R. The first check in rapply's code in both version was: > > if (typeof(object) != "list") > stop("'object' must be a list") > > Wrapping list() around the first argument and switching to using eval with > an expression-object rather than a call-object seemed to solve the problem > when this was posed as a question on StackOverflow, but Dayne was not happy > with that solution for other reasons that he is not describing. > > -- > David. > > > In R-3.1.3 we got > > rapply(list(quote(1+myNumber)), evalq, envir=list2env(list(myNumber=17))) > > #[1] 18 > > rapply(list(quote(1+myNumber)), eval, envir=list2env(list(myNumber=17))) > > #Error in (function (expr, envir = parent.frame(), enclos = if > > (is.list(envir) || : > > object 'myNumber' not found > > lapply(list(quote(1+myNumber)), evalq, envir=list2env(list(myNumber=17))) > > #Error in eval(substitute(expr), envir, enclos) : object 'X' not found > > lapply(list(quote(1+myNumber)), eval, envir=list2env(list(myNumber=17))) > > #[[1]] > > #[1] 18 > > while in R-3.2.0 we get > > rapply(list(quote(1+myNumber)), evalq, envir=list2env(list(myNumber=17))) > > #Error in eval(substitute(expr), envir, enclos) : object 'X' not found > > rapply(list(quote(1+myNumber)), eval, envir=list2env(list(myNumber=17))) > > #[1] 18 > > lapply(list(quote(1+myNumber)), evalq, envir=list2env(list(myNumber=17))) > > #Error in eval(substitute(expr), envir, enclos) : object 'X' not found > > lapply(list(quote(1+myNumber)), eval, envir=list2env(list(myNumber=17))) > > #[[1]] > > #[1] 18 > > > > Make the FUN argument function(arg)sys.call() to see some details of the > > change. > > > > > > Bill Dunlap > > TIBCO Software > > wdunlap tibco.com > > > > On Wed, Jul 15, 2015 at 12:35 PM, Dayne Filer > wrote: > > > >> In 3.1.2 eval does not store the result of the bquote-generated call in > >> the given environment. Interestingly, in 3.2.1 eval does store the > result > >> of the bquote-generated call in the given environment. > >> > >> In other words if I run the given example with eval rather than evalq, > on > >> 3.1.2 "x" is never stored in "fenv," but it is when I run the same code > on > >> 3.2.1. However, the given example stores "x" in "fenv" on 3.1.2, but > throws > >> the error I gave when run on 3.2.1. > >> > >> To give credit, I received the idea for using evalq from SO: > >> http://stackoverflow.com/a/22559385 > >> > >> Dayne > >> > >> > >> On Wed, Jul 15, 2015 at 3:29 PM, William Dunlap > wrote: > >> > >>> I am curious why you used evalq instead of eval in this code. > >>> > >>> Bill Dunlap > >>> TIBCO Software > >>> wdunlap tibco.com > >>> > >>> On Wed, Jul 15, 2015 at 11:49 AM, Dayne Filer > >>> wrote: > >>> > Hello, > > I upgraded from 3.1.2 to 3.2.1 and am receiving errors on code that > worked > as I intended previously. Briefly, I am using bquote to generate > expressions to modify data.table objects within a function, so I need > the > changes to actually be stored in the given environment. Previously, I > used > code like the following: > > test <- list(bquote(x <- 10)) > fenv <- environment() > rapply(test, evalq, envir = fenv) > > Although the code in the example above is much simpler, it shows the > problem. On 3.1.2 the expression is evaluated and x is stored as 10 in > the > given environment, fenv. In 3.2.1 the code throws an error: > > Error in eval(substitute(expr), envir, enclos) : object 'X' not found > > I could not find anything in the release notes that would explain this > change. Changing evalq to eval works in 3.2.1, but eval does not > store x > in > the given environment in 3.1.2. > > Thanks, > > Dayne > > [[alternative HTML version deleted]] > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mail
Re: [Rd] bquote/evalq behavior changed in R-3.2.1
David, If you are referring to the solution that would be: rapply(list(test), eval, envir = fenv) I thought I explained in the question that the above code does not work. It does not throw an error, but the behavior is no different (at least in the output or result). Using the above code still results in the x object not being stored in fenv on 3.1.2. Dayne On Wed, Jul 15, 2015 at 4:40 PM, William Dunlap wrote: > Another aspect of the change is (using TERR's RinR package): > > options(REvaluators=list(makeREvaluator("R-3.1.3"), >makeREvaluator("R-3.2.0"))) > > RCompare(rapply(list(quote(function(x)x),list(quote(pi),quote(7-4))), > function(arg)typeof(arg))) > R version 3.1.3 (2015-03-09) R version 3.2.0 (2015-04-16) > [1,] [1] "closure" "double" [1] "language" "symbol" > [2,] [3] "double" [3] "language" > $all.equal > $all.equal$`R version 3.1.3 (2015-03-09) vs. R version 3.2.0 > (2015-04-16)` > [1] "3 string mismatches" > > I prefer the new semantics, but it is a change. > > > > Bill Dunlap > TIBCO Software > wdunlap tibco.com > > On Wed, Jul 15, 2015 at 1:25 PM, David Winsemius > wrote: > >> >> On Jul 15, 2015, at 12:51 PM, William Dunlap wrote: >> >> > I think rapply() was changed to act like lapply() in this respect. >> > >> >> When I looked at the source of the difference, it was that typeof() >> returned 'language' in 3.2.1, while it returned 'list' in the earlier >> version of R. The first check in rapply's code in both version was: >> >> if (typeof(object) != "list") >> stop("'object' must be a list") >> >> Wrapping list() around the first argument and switching to using eval >> with an expression-object rather than a call-object seemed to solve the >> problem when this was posed as a question on StackOverflow, but Dayne was >> not happy with that solution for other reasons that he is not describing. >> >> -- >> David. >> >> > In R-3.1.3 we got >> > rapply(list(quote(1+myNumber)), evalq, >> envir=list2env(list(myNumber=17))) >> > #[1] 18 >> > rapply(list(quote(1+myNumber)), eval, envir=list2env(list(myNumber=17))) >> > #Error in (function (expr, envir = parent.frame(), enclos = if >> > (is.list(envir) || : >> > object 'myNumber' not found >> > lapply(list(quote(1+myNumber)), evalq, >> envir=list2env(list(myNumber=17))) >> > #Error in eval(substitute(expr), envir, enclos) : object 'X' not found >> > lapply(list(quote(1+myNumber)), eval, envir=list2env(list(myNumber=17))) >> > #[[1]] >> > #[1] 18 >> > while in R-3.2.0 we get >> > rapply(list(quote(1+myNumber)), evalq, >> envir=list2env(list(myNumber=17))) >> > #Error in eval(substitute(expr), envir, enclos) : object 'X' not found >> > rapply(list(quote(1+myNumber)), eval, envir=list2env(list(myNumber=17))) >> > #[1] 18 >> > lapply(list(quote(1+myNumber)), evalq, >> envir=list2env(list(myNumber=17))) >> > #Error in eval(substitute(expr), envir, enclos) : object 'X' not found >> > lapply(list(quote(1+myNumber)), eval, envir=list2env(list(myNumber=17))) >> > #[[1]] >> > #[1] 18 >> > >> > Make the FUN argument function(arg)sys.call() to see some details of the >> > change. >> > >> > >> > Bill Dunlap >> > TIBCO Software >> > wdunlap tibco.com >> > >> > On Wed, Jul 15, 2015 at 12:35 PM, Dayne Filer >> wrote: >> > >> >> In 3.1.2 eval does not store the result of the bquote-generated call in >> >> the given environment. Interestingly, in 3.2.1 eval does store the >> result >> >> of the bquote-generated call in the given environment. >> >> >> >> In other words if I run the given example with eval rather than evalq, >> on >> >> 3.1.2 "x" is never stored in "fenv," but it is when I run the same >> code on >> >> 3.2.1. However, the given example stores "x" in "fenv" on 3.1.2, but >> throws >> >> the error I gave when run on 3.2.1. >> >> >> >> To give credit, I received the idea for using evalq from SO: >> >> http://stackoverflow.com/a/22559385 >> >> >> >> Dayne >> >> >> >> >> >> On Wed, Jul 15, 2015 at 3:29 PM, William Dunlap >> wrote: >> >> >> >>> I am curious why you used evalq instead of eval in this code. >> >>> >> >>> Bill Dunlap >> >>> TIBCO Software >> >>> wdunlap tibco.com >> >>> >> >>> On Wed, Jul 15, 2015 at 11:49 AM, Dayne Filer >> >>> wrote: >> >>> >> Hello, >> >> I upgraded from 3.1.2 to 3.2.1 and am receiving errors on code that >> worked >> as I intended previously. Briefly, I am using bquote to generate >> expressions to modify data.table objects within a function, so I >> need >> the >> changes to actually be stored in the given environment. Previously, I >> used >> code like the following: >> >> test <- list(bquote(x <- 10)) >> fenv <- environment() >> rapply(test, evalq, envir = fenv) >> >> Although the code in the example above is much simpler, it shows the >> problem. On 3.1.2 the expression is evaluated and x is stored as 10 >> in >> the >> given en
Re: [Rd] bquote/evalq behavior changed in R-3.2.1
Bill, Is your conclusion to just update the code and enforce using the most recent version of R? Dayne On Wed, Jul 15, 2015 at 4:44 PM, Dayne Filer wrote: > David, > > If you are referring to the solution that would be: > > rapply(list(test), eval, envir = fenv) > > I thought I explained in the question that the above code does not work. > It does not throw an error, but the behavior is no different (at least in > the output or result). Using the above code still results in the x object > not being stored in fenv on 3.1.2. > > Dayne > > On Wed, Jul 15, 2015 at 4:40 PM, William Dunlap wrote: > >> Another aspect of the change is (using TERR's RinR package): >> > options(REvaluators=list(makeREvaluator("R-3.1.3"), >>makeREvaluator("R-3.2.0"))) >> > RCompare(rapply(list(quote(function(x)x),list(quote(pi),quote(7-4))), >> function(arg)typeof(arg))) >> R version 3.1.3 (2015-03-09) R version 3.2.0 (2015-04-16) >> [1,] [1] "closure" "double" [1] "language" "symbol" >> [2,] [3] "double" [3] "language" >> $all.equal >> $all.equal$`R version 3.1.3 (2015-03-09) vs. R version 3.2.0 >> (2015-04-16)` >> [1] "3 string mismatches" >> >> I prefer the new semantics, but it is a change. >> >> >> >> Bill Dunlap >> TIBCO Software >> wdunlap tibco.com >> >> On Wed, Jul 15, 2015 at 1:25 PM, David Winsemius >> wrote: >> >>> >>> On Jul 15, 2015, at 12:51 PM, William Dunlap wrote: >>> >>> > I think rapply() was changed to act like lapply() in this respect. >>> > >>> >>> When I looked at the source of the difference, it was that typeof() >>> returned 'language' in 3.2.1, while it returned 'list' in the earlier >>> version of R. The first check in rapply's code in both version was: >>> >>> if (typeof(object) != "list") >>> stop("'object' must be a list") >>> >>> Wrapping list() around the first argument and switching to using eval >>> with an expression-object rather than a call-object seemed to solve the >>> problem when this was posed as a question on StackOverflow, but Dayne was >>> not happy with that solution for other reasons that he is not describing. >>> >>> -- >>> David. >>> >>> > In R-3.1.3 we got >>> > rapply(list(quote(1+myNumber)), evalq, >>> envir=list2env(list(myNumber=17))) >>> > #[1] 18 >>> > rapply(list(quote(1+myNumber)), eval, >>> envir=list2env(list(myNumber=17))) >>> > #Error in (function (expr, envir = parent.frame(), enclos = if >>> > (is.list(envir) || : >>> > object 'myNumber' not found >>> > lapply(list(quote(1+myNumber)), evalq, >>> envir=list2env(list(myNumber=17))) >>> > #Error in eval(substitute(expr), envir, enclos) : object 'X' not found >>> > lapply(list(quote(1+myNumber)), eval, >>> envir=list2env(list(myNumber=17))) >>> > #[[1]] >>> > #[1] 18 >>> > while in R-3.2.0 we get >>> > rapply(list(quote(1+myNumber)), evalq, >>> envir=list2env(list(myNumber=17))) >>> > #Error in eval(substitute(expr), envir, enclos) : object 'X' not found >>> > rapply(list(quote(1+myNumber)), eval, >>> envir=list2env(list(myNumber=17))) >>> > #[1] 18 >>> > lapply(list(quote(1+myNumber)), evalq, >>> envir=list2env(list(myNumber=17))) >>> > #Error in eval(substitute(expr), envir, enclos) : object 'X' not found >>> > lapply(list(quote(1+myNumber)), eval, >>> envir=list2env(list(myNumber=17))) >>> > #[[1]] >>> > #[1] 18 >>> > >>> > Make the FUN argument function(arg)sys.call() to see some details of >>> the >>> > change. >>> > >>> > >>> > Bill Dunlap >>> > TIBCO Software >>> > wdunlap tibco.com >>> > >>> > On Wed, Jul 15, 2015 at 12:35 PM, Dayne Filer >>> wrote: >>> > >>> >> In 3.1.2 eval does not store the result of the bquote-generated call >>> in >>> >> the given environment. Interestingly, in 3.2.1 eval does store the >>> result >>> >> of the bquote-generated call in the given environment. >>> >> >>> >> In other words if I run the given example with eval rather than >>> evalq, on >>> >> 3.1.2 "x" is never stored in "fenv," but it is when I run the same >>> code on >>> >> 3.2.1. However, the given example stores "x" in "fenv" on 3.1.2, but >>> throws >>> >> the error I gave when run on 3.2.1. >>> >> >>> >> To give credit, I received the idea for using evalq from SO: >>> >> http://stackoverflow.com/a/22559385 >>> >> >>> >> Dayne >>> >> >>> >> >>> >> On Wed, Jul 15, 2015 at 3:29 PM, William Dunlap >>> wrote: >>> >> >>> >>> I am curious why you used evalq instead of eval in this code. >>> >>> >>> >>> Bill Dunlap >>> >>> TIBCO Software >>> >>> wdunlap tibco.com >>> >>> >>> >>> On Wed, Jul 15, 2015 at 11:49 AM, Dayne Filer >> > >>> >>> wrote: >>> >>> >>> Hello, >>> >>> I upgraded from 3.1.2 to 3.2.1 and am receiving errors on code that >>> worked >>> as I intended previously. Briefly, I am using bquote to generate >>> expressions to modify data.table objects within a function, so I >>> need >>> the >>> changes to actually be stored in the given environment. Previously, >>> I >>> used >>> >>
Re: [Rd] bquote/evalq behavior changed in R-3.2.1
You could test for the version of R when using rapply. > getRversion() >= "3.2.0" [1] TRUE I rarely use rapply(). I often find that writing my own purpose-built recursive function is easier than fitting my problem into rapply's framework. Bill Dunlap TIBCO Software wdunlap tibco.com On Wed, Jul 15, 2015 at 1:46 PM, Dayne Filer wrote: > Bill, > > Is your conclusion to just update the code and enforce using the most > recent version of R? > > Dayne > > On Wed, Jul 15, 2015 at 4:44 PM, Dayne Filer > wrote: > >> David, >> >> If you are referring to the solution that would be: >> >> rapply(list(test), eval, envir = fenv) >> >> I thought I explained in the question that the above code does not work. >> It does not throw an error, but the behavior is no different (at least in >> the output or result). Using the above code still results in the x object >> not being stored in fenv on 3.1.2. >> >> Dayne >> >> On Wed, Jul 15, 2015 at 4:40 PM, William Dunlap >> wrote: >> >>> Another aspect of the change is (using TERR's RinR package): >>> > options(REvaluators=list(makeREvaluator("R-3.1.3"), >>>makeREvaluator("R-3.2.0"))) >>> > RCompare(rapply(list(quote(function(x)x),list(quote(pi),quote(7-4))), >>> function(arg)typeof(arg))) >>> R version 3.1.3 (2015-03-09) R version 3.2.0 (2015-04-16) >>> [1,] [1] "closure" "double" [1] "language" "symbol" >>> [2,] [3] "double" [3] "language" >>> $all.equal >>> $all.equal$`R version 3.1.3 (2015-03-09) vs. R version 3.2.0 >>> (2015-04-16)` >>> [1] "3 string mismatches" >>> >>> I prefer the new semantics, but it is a change. >>> >>> >>> >>> Bill Dunlap >>> TIBCO Software >>> wdunlap tibco.com >>> >>> On Wed, Jul 15, 2015 at 1:25 PM, David Winsemius >> > wrote: >>> On Jul 15, 2015, at 12:51 PM, William Dunlap wrote: > I think rapply() was changed to act like lapply() in this respect. > When I looked at the source of the difference, it was that typeof() returned 'language' in 3.2.1, while it returned 'list' in the earlier version of R. The first check in rapply's code in both version was: if (typeof(object) != "list") stop("'object' must be a list") Wrapping list() around the first argument and switching to using eval with an expression-object rather than a call-object seemed to solve the problem when this was posed as a question on StackOverflow, but Dayne was not happy with that solution for other reasons that he is not describing. -- David. > In R-3.1.3 we got > rapply(list(quote(1+myNumber)), evalq, envir=list2env(list(myNumber=17))) > #[1] 18 > rapply(list(quote(1+myNumber)), eval, envir=list2env(list(myNumber=17))) > #Error in (function (expr, envir = parent.frame(), enclos = if > (is.list(envir) || : > object 'myNumber' not found > lapply(list(quote(1+myNumber)), evalq, envir=list2env(list(myNumber=17))) > #Error in eval(substitute(expr), envir, enclos) : object 'X' not found > lapply(list(quote(1+myNumber)), eval, envir=list2env(list(myNumber=17))) > #[[1]] > #[1] 18 > while in R-3.2.0 we get > rapply(list(quote(1+myNumber)), evalq, envir=list2env(list(myNumber=17))) > #Error in eval(substitute(expr), envir, enclos) : object 'X' not found > rapply(list(quote(1+myNumber)), eval, envir=list2env(list(myNumber=17))) > #[1] 18 > lapply(list(quote(1+myNumber)), evalq, envir=list2env(list(myNumber=17))) > #Error in eval(substitute(expr), envir, enclos) : object 'X' not found > lapply(list(quote(1+myNumber)), eval, envir=list2env(list(myNumber=17))) > #[[1]] > #[1] 18 > > Make the FUN argument function(arg)sys.call() to see some details of the > change. > > > Bill Dunlap > TIBCO Software > wdunlap tibco.com > > On Wed, Jul 15, 2015 at 12:35 PM, Dayne Filer wrote: > >> In 3.1.2 eval does not store the result of the bquote-generated call in >> the given environment. Interestingly, in 3.2.1 eval does store the result >> of the bquote-generated call in the given environment. >> >> In other words if I run the given example with eval rather than evalq, on >> 3.1.2 "x" is never stored in "fenv," but it is when I run the same code on >> 3.2.1. However, the given example stores "x" in "fenv" on 3.1.2, but throws >> the error I gave when run on 3.2.1. >> >> To give credit, I received the idea for using evalq from SO: >> http://stackoverflow.com/a/22559385 >> >> Dayne >> >> >> On Wed, Jul 15, 2015 at 3:29 PM, William Dunlap wrote: >> >>> I am curious why you used evalq instead of eval in this code. >>> >>> Bill Dunlap >>> TIBCO Software >>> wdu