From luke-tierney at uiowa.edu  Mon Mar  2 00:52:28 2015
From: luke-tierney at uiowa.edu (luke-tierney at uiowa.edu)
Date: Sun, 1 Mar 2015 17:52:28 -0600
Subject: [Rd] iterated lapply
In-Reply-To: <alpine.DEB.2.02.1503011742280.2327@luke-Latitude>
References: <mailman.21.1424775604.19275.r-devel@r-project.org>
	<20150224113908.GA7612@cs.toronto.edu>
	<alpine.DEB.2.02.1502240950150.2336@luke-Latitude>
	<CAF8bMcbu93drmsDEc6DpSiKpb1sx-ufMZhC81Z5pp+c4ZzpxFw@mail.gmail.com>
	<alpine.DEB.2.02.1503011742280.2327@luke-Latitude>
Message-ID: <alpine.DEB.2.02.1503011751160.2327@luke-Latitude>

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


[Rd] iterated lapply
luke-tierney at uiowa.edu