[Rd] iterated lapply
luke-tierney at uiowa.edu
luke-tierney at uiowa.edu
Mon Mar 2 00:48:06 CET 2015
On Thu, 26 Feb 2015, William Dunlap wrote:
> ...
> It also seems to cause problems with some built-in functions:
> newlapply <- function (X, FUN, ...)
> {
> FUN <- match.fun(FUN)
> if (!is.list(X))
> X <- as.list(X)
> rval <- vector("list", length(X))
> for (i in seq(along = X)) {
> rval[i] <- list(local({
> i <- i
> FUN(X[[i]], ...)
> }))
> }
> names(rval) <- names(X)
> return(rval)
> }
> newlapply(1:2,log)
> #Error in FUN(X[[i]], ...) : non-numeric argument to mathematical function
This seems to be a bug in log() -- this takes local() out of the issue:
> f <- function(x, ...) {
+ g <- function()
+ log(x, ...)
+ g()
+ }
> f(1)
Error in log(x, ...) : non-numeric argument to mathematical function
It's not following the ... properly for some reason.
Best,
luke
--
Luke Tierney
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa Phone: 319-335-3386
Department of Statistics and Fax: 319-335-3017
Actuarial Science
241 Schaeffer Hall email: luke-tierney at uiowa.edu
Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu
More information about the R-devel
mailing list