[Rd] should lapply preserve attributes?

Timothy H. Keitt Timothy.Keitt@stonybrook.edu
19 Mar 2002 16:15:47 -0500

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)

Would it make sense to replace

	names(rval) <- names(X)


	attributes(rval) <- attributes(X)

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


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
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