Re: [Rd] premature use of startsWith in r75110

2018-08-13 Thread Kurt Hornik
> Hugh Parsonage writes: Thanks, will fix. Best -k > In r75110 at line 1846 in src/library/tools/R/check.R the following > line was changed > - if(length(grep("^Found the defunct/removed function", out8))) > + if(any(startsWith(out8, "Found the defunct/removed function"))) > However, if `o

[Rd] premature use of startsWith in r75110

2018-08-13 Thread Hugh Parsonage
In r75110 at line 1846 in src/library/tools/R/check.R the following line was changed - if(length(grep("^Found the defunct/removed function", out8))) + if(any(startsWith(out8, "Found the defunct/removed function"))) However, if `out8` is NULL at this point (which is plausible), the original return

Re: [Rd] trace in uniroot() ?

2018-08-13 Thread William Dunlap via R-devel
To record the value of the function as well as the arguments, you can use the following instrumentObjectiveFunction <- function(FUN) { newFUN <- local({ INFO <- list() function(...) { value <- FUN(...) INFO[[length(INFO)+1]] <<- list(args=list(...), valu

Re: [Rd] substitute() on arguments in ellipsis ("dot dot dot")?

2018-08-13 Thread Hadley Wickham
Since you're already using bang-bang ;) library(rlang) dots1 <- function(...) as.list(substitute(list(...)))[-1L] dots2 <- function(...) as.list(substitute(...())) dots3 <- function(...) match.call(expand.dots = FALSE)[["..."]] dots4 <- function(...) exprs(...) bench::mark( dots1(1+2, "a", rno

Re: [Rd] trace in uniroot() ?

2018-08-13 Thread J C Nash
Despite my years with R, I didn't know about trace(). Thanks. However, my decades in the minimization and root finding game make me like having a trace that gives some info on the operation, the argument and the current function value. I've usually found glitches are a result of things like >= r

Re: [Rd] trace in uniroot() ?

2018-08-13 Thread William Dunlap via R-devel
I tend to avoid the the trace/verbose arguments for the various root finders and optimizers and instead use the trace function or otherwise modify the function handed to the operator. You can print or plot the arguments or save them. E.g., > trace(ff, print=FALSE, quote(cat("x=", deparse(x), "\n

Re: [Rd] apply with zero-row matrix

2018-08-13 Thread William Dunlap via R-devel
vapply has a mandatory FUN.VALUE argument which specifies the type and size of FUN's return value. This helps when you want to cover the 0-length case without 'if' statements. You can change your apply calls to vapply calls, but they will be a bit more complicated. E.g., change apply(X=myMat

[Rd] vector arithmetic

2018-08-13 Thread isomorphismes
I'm looking for where in the source recycling and vector multiplication+addition are defined. I see some stuff in ~/src/main/arithmetic.c. Is there anywhere else I should be looking as well? Cheers -- isomorphi...@sdf.org SDF Public Access UNIX System - http://sdf.org ___

Re: [Rd] Package compiler - efficiency problem

2018-08-13 Thread Tomas Kalibera
Dear Karol, thank you for the report. I can reproduce that the function from you example takes very long to compile and I can see where most time is spent. The compiler is itself written in R and requires a lot of resources for large functions (foo() has over 16,000 lines of code, nearly 1 mil

Re: [Rd] substitute() on arguments in ellipsis ("dot dot dot")?

2018-08-13 Thread Henrik Bengtsson
Thanks all, this was very helpful. Peter's finding - dots2() below - is indeed interesting - I'd be curious to learn what goes on there. The different alternatives perform approximately the same; dots1 <- function(...) as.list(substitute(list(...)))[-1L] dots2 <- function(...) as.list(substitute