[Rd] RFC: getifexists() {was [Bug 16065] "exists" ...}

2015-01-08 Thread Martin Maechler
In November, we had a "bug repository conversation" with Peter Hagerty and myself: https://bugs.r-project.org/bugzilla/show_bug.cgi?id=16065 where the bug report title started with --->> "exists" is a bottleneck for dispatch and package loading, ... Peter proposed an extra simplified and he

Re: [Rd] RFC: getifexists() {was [Bug 16065] "exists" ...}

2015-01-08 Thread Duncan Murdoch
On 08/01/2015 4:16 AM, Martin Maechler wrote: > In November, we had a "bug repository conversation" > with Peter Hagerty and myself: > > https://bugs.r-project.org/bugzilla/show_bug.cgi?id=16065 > > where the bug report title started with > > --->> "exists" is a bottleneck for dispatch and p

Re: [Rd] gsub with perl=TRUE results in 'this version of PCRE is not compiled with Unicode property support' in R-devel

2015-01-08 Thread Prof Brian Ripley
Why are you reporting that your PCRE library does not have something which the R-admin manual says it should preferably have? To wit, footnote 37 says 'and not PCRE2, which started at version 10.0. PCRE must be built with UTF-8 support (not the default) and support for Unicode properties is

[Rd] On base::rank

2015-01-08 Thread Arunkumar Srinivasan
Have a look at the following, taken from base::rank: ... if (!is.na(na.last) && any(nas)) { yy <- integer(length(x)) # <~ storage.mode(yy) <- storage.mode(y) # < yy <- NA NAkeep <- (na.last == "keep") if (NAkeep || na.last) {

Re: [Rd] New version of Rtools for Windows

2015-01-08 Thread Avraham Adler
Very timely, as this is how I got into the problem I posted about earlier; maybe some of the problems I ran into will mean more to the you and the experts on this thread, Dr. Murdoch.For reference, I run Windows 7 64bit, and I am trying to build a 64 bit version of R-3.1.2. As we discussed offline

Re: [Rd] New version of Rtools for Windows

2015-01-08 Thread Henric Winell
On 2015-01-08 14:18, Avraham Adler wrote: Very timely, as this is how I got into the problem I posted about earlier; maybe some of the problems I ran into will mean more to the you and the experts on this thread, Dr. Murdoch.For reference, I run Windows 7 64bit, and I am trying to build a 64 bit

Re: [Rd] RFC: getifexists() {was [Bug 16065] "exists" ...}

2015-01-08 Thread John Nolan
Adding an optional argument to get (and mget) like val <- get(name, where, ..., value.if.not.found=NULL ) (*) would be useful for many. HOWEVER, it is possible that there could be some confusion here: (*) can give a NULL because either x exists and has value NULL, or because x doesn't exist.

Re: [Rd] On base::rank

2015-01-08 Thread Martin Maechler
> Arunkumar Srinivasan > on Thu, 8 Jan 2015 13:46:57 +0100 writes: > Have a look at the following, taken from base::rank: > ... > if (!is.na(na.last) && any(nas)) { > yy <- integer(length(x)) # <~ > storage.mode(yy) <- storage.mode(y) # < >

Re: [Rd] On base::rank

2015-01-08 Thread Arunkumar Srinivasan
> Indeed. Interesting that nobody has noticed till now, > even though that part has been world readable since at least 2008-08-25. That was what made me a bit unsure :-). > Note that the R source code is at > http://svn.r-project.org/R/ > and the file in question at > http://svn.r-pro

Re: [Rd] RFC: getifexists() {was [Bug 16065] "exists" ...}

2015-01-08 Thread Duncan Murdoch
On 08/01/2015 9:03 AM, John Nolan wrote: Adding an optional argument to get (and mget) like val <- get(name, where, ..., value.if.not.found=NULL ) (*) That would be a bad idea, as it would change behaviour of existing uses of get(). What I suggested would not give a default. If the arg wa

Re: [Rd] gsub with perl=TRUE results in 'this version of PCRE is not compiled with Unicode property support' in R-devel

2015-01-08 Thread Kasper Daniel Hansen
Dan, for OS X, there is a new pcre library posted at http://r.research.att.com/libs/ with a date stamp of Dec 28. This fixes this problem. You can test for this by running make check post compilation. It'll bang out with a failure if this is not in order. (And I know that all of this is descr

Re: [Rd] RFC: getifexists() {was [Bug 16065] "exists" ...}

2015-01-08 Thread Michael Lawrence
If we do add an argument to get(), then it should be named consistently with the ifnotfound argument of mget(). As mentioned, the possibility of a NULL value is problematic. One solution is a sentinel value that indicates an unbound value (like R_UnboundValue). But another idea (and one pretty sim

Re: [Rd] RFC: getifexists() {was [Bug 16065] "exists" ...}

2015-01-08 Thread Martin Maechler
> Adding an optional argument to get (and mget) like > val <- get(name, where, ..., value.if.not.found=NULL ) (*) > would be useful for many. HOWEVER, it is possible that there could be > some confusion here: (*) can give a NULL because either x exists and > has value NULL, or because x does

[Rd] unloadNamespace

2015-01-08 Thread Paul Gilbert
In the documentation the closed thing I see to an explanation of this is that ?detach says "Unloading some namespaces has undesirable side effects" Can anyone explain why unloading tseries will load zoo? I don't think this behavior is specific to tseries, it's just an example. I realize one wo

Re: [Rd] New version of Rtools for Windows

2015-01-08 Thread Hin-Tak Leung
The r.dll crash is easy - you need to be using gcc-ar for ar, and gcc-ranlib for ranlib. I also posted a patch to fix the check failure for stack probing, as lto optimizes away the stack probing code, as it should. yes, lto build's speed gain is very impressive. -

Re: [Rd] unloadNamespace

2015-01-08 Thread Gabriel Becker
Paul, My switchr package (https://github.com/gmbecker/switchr) has the flushSession function which does what you want and seems to work (on my test machine at least). I havent tested it under a recent Rdevel, or with that specific package, however I will soon, as the overarching model of switchr

Re: [Rd] New version of Rtools for Windows

2015-01-08 Thread Avraham Adler
On Thu, Jan 8, 2015 at 10:48 AM, Hin-Tak Leung wrote: > > The r.dll crash is easy - you need to be using gcc-ar for ar, and gcc-ranlib > for ranlib. I also posted a patch to fix the check failure for stack probing, > as lto optimizes away the stack probing code, as it should. > > yes, lto build'

Re: [Rd] New version of Rtools for Windows

2015-01-08 Thread Hin-Tak Leung
Oh, I forgot to mention that besides setting AR, RANLIB and the stack probing fix, you also need a very up to date binutils. 2.25 was out in december. Even with that , if you linker's default is not what you are compiling for (i.e. a multiarch toolchain), you need to set GNUTARGET also, i.e. -m3

Re: [Rd] RFC: getifexists() {was [Bug 16065] "exists" ...}

2015-01-08 Thread luke-tierney
On Thu, 8 Jan 2015, Michael Lawrence wrote: If we do add an argument to get(), then it should be named consistently with the ifnotfound argument of mget(). As mentioned, the possibility of a NULL value is problematic. One solution is a sentinel value that indicates an unbound value (like R_Unbou

[Rd] Testing R packages on Solaris Studio

2015-01-08 Thread Jeroen Ooms
I have setup a Solaris server to test packages before submitting to CRAN, in order to catch problems that might not reveal themselves on Fedora, Debian, OSX or Windows. The machine runs a Solaris 11.2 vm with Solaris Studio 12.3. I was able to compile current r-devel using the suggested environmen

Re: [Rd] RFC: getifexists() {was [Bug 16065] "exists" ...}

2015-01-08 Thread Jeroen Ooms
On Thu, Jan 8, 2015 at 6:36 AM, Duncan Murdoch wrote: >> val <- get(name, where, ..., value.if.not.found=NULL ) (*) > > That would be a bad idea, as it would change behaviour of existing uses of > get(). Another approach would be if the "not found" behavior consists of a callback, e.g. an expre

Re: [Rd] setequal: better readability, reduced memory footprint, and minor speedup

2015-01-08 Thread peter dalgaard
If you look at the definition of %in%, you'll find that it is implemented using match, so if we did as you suggest, I give it about three days before someone suggests to inline the function call... Readability of source code is not usually our prime concern. The && idea does have some merit, th

Re: [Rd] RFC: getifexists() {was [Bug 16065] "exists" ...}

2015-01-08 Thread Peter Haverty
For what it's worth, I think we would need a new function if the default behavior changes. Since we already have "get" and "mget", maybe "cget" for "conditional get"? "if get", "safe get", ... I like the idea of keeping the original "not found" behavior if the "if.not.found" arg is missing. Howe

Re: [Rd] RFC: getifexists() {was [Bug 16065] "exists" ...}

2015-01-08 Thread Peter Haverty
Michael's idea has an interesting bonus that he and I discussed earlier. It would be very convenient to have a container of key/value pairs. I imagine many people often write this: x - mapply( names(x), x, FUN=function(k,v) { # work with key and value } especially ex perl people accustomed to w

Re: [Rd] RFC: getifexists() {was [Bug 16065] "exists" ...}

2015-01-08 Thread Michael Lawrence
On Thu, Jan 8, 2015 at 11:57 AM, wrote: > On Thu, 8 Jan 2015, Michael Lawrence wrote: > > If we do add an argument to get(), then it should be named consistently >> with the ifnotfound argument of mget(). As mentioned, the possibility of a >> NULL value is problematic. One solution is a sentinel

[Rd] latex warning

2015-01-08 Thread Gábor Csárdi
Dear all, I am getting an R CMD check warning about the PDF manual. I am having a hard time finding out what is wrong, here is the log of the Rd2pdf call. The full check (and other) log is at https://api.travis-ci.org/jobs/46373922/log.txt?deansi=true if anybody is interested, and the package its

Re: [Rd] setequal: better readability, reduced memory footprint, and minor speedup

2015-01-08 Thread William Dunlap
> why is there no setcontains()? Several packages define is.subset(), which I am assuming is what you are proposing, but it its arguments reversed. E.g., package:algstat has is.subset <- function(x, y) all(x %in% y) containsQ <- function(y, x) all(x %in% y) and package:rje has essentially t

Re: [Rd] setequal: better readability, reduced memory footprint, and minor speedup

2015-01-08 Thread Peter Haverty
How about unique them both and compare the lengths? It's less work, especially allocation. Pete Peter M. Haverty, Ph.D. Genentech, Inc. phave...@gene.com On Thu, Jan 8, 2015 at 1:30 PM, peter dalgaard wrote: > If you look at the definition of %in%, you'll find that it i

Re: [Rd] setequal: better readability, reduced memory footprint, and minor speedup

2015-01-08 Thread Michael Lawrence
Currently unique() does duplicated() internally and then extracts. One could make a countUnique that simply counts, rather than allocate the logical return value of duplicated(). But so much of the cost is in the hash operation that it probably won't help much, but that might depend on the sizes of

Re: [Rd] setequal: better readability, reduced memory footprint, and minor speedup

2015-01-08 Thread Peter Haverty
Try this out. It looks like a 2X speedup for some cases and a wash in others. "unique" does two allocations, but skipping the "> 0L" allocation could make up for it. library(microbenchmark) library(RUnit) x = sample.int(1e4, 1e5, TRUE) y = sample.int(1e4, 1e5, TRUE) set_equal <- function(x, y)

Re: [Rd] setequal: better readability, reduced memory footprint, and minor speedup

2015-01-08 Thread Peter Haverty
I was thinking something like: setequal <- function(x,y) { xu = unique(x) yu = unique(y) if (length(xu) != length(yu)) { return FALSE; } return (all( match( xu, yu, 0L ) > 0L ) ) } This lets you fail early for cheap (skipping the allocation from the ">0L"s). Whether or not this goes fast depends

Re: [Rd] setequal: better readability, reduced memory footprint, and minor speedup

2015-01-08 Thread Hervé Pagès
On 01/08/2015 01:30 PM, peter dalgaard wrote: If you look at the definition of %in%, you'll find that it is implemented using match, so if we did as you suggest, I give it about three days before someone suggests to inline the function call... But you wouldn't bet money on that right? Because

Re: [Rd] New version of Rtools for Windows

2015-01-08 Thread Avraham Adler
Regarding the redefinition error, I've asked on StackOverflow for advice [1], but I have noticed the following; perhaps someone here can understand what changed between the stdio.h of 4.6.3 and the stdio.h of 4.8.4. In GCC 4.8.4, the section of stdio.h which is referenced in the errors is the follo