l <- list(x = 1:500, y = runif(500), z = 500:1)
df <- as_data_frame(l)
m <- matrix(rnorm(50), ncol = 5)
colnames(m) <- c("a", "b", "c", "d", "e")
df <- as_data_frame(m)
# as_data_frame is considerably simpler than as.data.frame
# making it more suitable for use when you have things that are
# lists
l2 <- replicate(26, sample(letters), simplify = FALSE)
names(l2) <- letters
microbenchmark::microbenchmark(
as_data_frame(l2, validate = FALSE),
as_data_frame(l2),
as.data.frame(l2)
)
m <- matrix(runif(26 * 100), ncol = 26)
colnames(m) <- letters
microbenchmark::microbenchmark(
as_data_frame(m),
as.data.frame(m)
)
Run the code above in your browser using DataLab