[Rd] as.list() for function:s

From: Henrik Bengtsson <hb_at_stat.berkeley.edu>
Date: Thu, 16 Oct 2008 12:51:40 -0700


Hi, a quick comment. I just notice that as.list() deals with function:s the old way inside the "default" function, cf.

> as.list.default

function (x, ...)
{

    if (typeof(x) == "list")

        return(x)
    if (is.function(x))

        return(c(formals(x), list(body(x))))     .Internal(as.vector(x, "list"))
}
<environment: namespace:base>

The following should do the same thing cleaner (and faster?):

as.list.function <- function(x, ...)
{

    c(formals(x), list(body(x)))
}

as.list.default <- function (x, ...)
{

    if (typeof(x) == "list")

        return(x)
    .Internal(as.vector(x, "list"))
}

/Henrik



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu 16 Oct 2008 - 19:53:18 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 17 Oct 2008 - 10:30:21 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive