On Fri, Jan 18, 2013 at 6:25 PM, John Merrill <john.merr...@gmail.com> wrote:
> Sure.  I'll write something up for the gallery, but here's the crude
> outline.
>
> Here's the C++ code:

Is C++ really necessary here?  I have the following R function in plyr:

quickdf <- function(list) {
  rows <- unique(unlist(lapply(list, NROW)))
  stopifnot(length(rows) == 1)

  names(list) <- make_names(list, "X")
  class(list) <- "data.frame"
  attr(list, "row.names") <- c(NA_integer_, -rows)

  list
}

which is basically equivalent (although I do some tricks with
rownames).  It's even more efficient if you copy and paste the
contents instead of calling the function because then that avoids
duplicating the input list, and instead modifies it in place.

Hadley

-- 
Chief Scientist, RStudio
http://had.co.nz/
_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to