On Tue, Dec 7, 2010 at 12:12 PM, Alexander Senger
<sen...@physik.hu-berlin.de> wrote:
> Hello Gerrit, Gabor,
>
>
> thank you for your suggestion.
>
> Unfortunately unlist seems to be rather expensive. A short test with one
> of my datasets gives 0.01s for an extraction based on my approach and
> 5.6s for unlist alone. The reason seems to be that unlist relies on
> lapply internally and does so recursively?
>
> Maybe there is still another way to go?
>

Too bad it wasn't faster but note that unlist does not rely on lapply.
  Here is the complete source of unlist and from it we see the key
portion is done internally, i.e. in C:

> unlist
function (x, recursive = TRUE, use.names = TRUE)
{
    if (.Internal(islistfactor(x, recursive))) {
        lv <- unique(.Internal(unlist(lapply(x, levels), recursive,
            FALSE)))
        nm <- if (use.names)
            names(.Internal(unlist(x, recursive, use.names)))
        res <- .Internal(unlist(lapply(x, as.character), recursive,
            FALSE))
        res <- match(res, lv)
        structure(res, levels = lv, names = nm, class = "factor")
    }
    else .Internal(unlist(x, recursive, use.names))
}
<environment: namespace:base>


-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to