From Timothy.Keitt@stonybrook.edu  Tue Mar 19 21:15:47 2002
From: Timothy.Keitt@stonybrook.edu (Timothy H. Keitt)
Date: 19 Mar 2002 16:15:47 -0500
Subject: [Rd] should lapply preserve attributes?
Message-ID: <1016572547.29959.23.camel@keittlab-6>

I have an application where I need to preserve object attributes across
calls to 'lapply'. The current definition is:

lapply <- function (X, FUN, ...) 
{
    FUN <- match.fun(FUN)
    if (!is.list(X)) 
        X <- as.list(X)
    rval <- .Internal(lapply(X, FUN))
    names(rval) <- names(X)
    return(rval)
}

Would it make sense to replace

	names(rval) <- names(X)

with

	attributes(rval) <- attributes(X)

?? I can, of course, make a local function for this, but wondered if
this change would be useful in general.

Cheers,
Tim

-- 
Timothy H. Keitt
Department of Ecology and Evolution
State University of New York at Stony Brook
Stony Brook, New York 11794 USA
Phone: 631-632-1101, FAX: 631-632-7626
http://life.bio.sunysb.edu/ee/keitt/
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] should lapply preserve attributes?
Timothy H. Keitt