[Rd] iterated lapply
luke-tierney at uiowa.edu
luke-tierney at uiowa.edu
Mon Mar 2 00:52:28 CET 2015
On Sun, 1 Mar 2015, luke-tierney at uiowa.edu wrote:
> 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.
But no longer a problem in R-devel -- maybe there is a change worth
back-porting to R-patched.
Best,
luke
> 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