From tim@t@yior m@iii@g oii hidde@eieph@@ts@co@uk  Thu Feb 10 23:51:28 2022
From: tim@t@yior m@iii@g oii hidde@eieph@@ts@co@uk (tim@t@yior m@iii@g oii hidde@eieph@@ts@co@uk)
Date: Thu, 10 Feb 2022 22:51:28 +0000 (GMT)
Subject: [Rd] Recent list2DF changes
Message-ID: <1376574877.27168.1644533488936@office.mailbox.org>

I noticed list2DF has recently been altered in R-devel to no longer replicate elements to the same length (instead giving an error). If useful, I *think* the following alternative would give the same performance improvements but maintain the current (4.1.2) recycling behaviour.

list2DF2 <- function (x = list(), nrow = NULL)
{
    stopifnot(is.list(x), is.null(nrow) || nrow >= 0L)
    if (n <- length(x)) {
        nn <- lengths(x)
        if (is.null(nrow))
            nrow <- max(nn, 0L)
        if (!all(nn==nrow))
            x <- lapply(x, rep_len, nrow)
    }
    else {
        if (is.null(nrow))
            nrow <- 0L
    }
    if (is.null(names(x)))
        names(x) <- character(n)
    class(x) <- "data.frame"
    attr(x, "row.names") <- .set_row_names(nrow)
    x
}

Tim



[Rd] Recent list2DF changes
tim@t@yior m@iii@g oii hidde@eieph@@ts@co@uk