tim@t@yior m@iii@g oii hidde@eieph@@ts@co@uk
2022-Feb-10 22:51 UTC
[Rd] Recent list2DF changes
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