search for: list_to_df

Displaying 1 result from an estimated 1 matches for "list_to_df".

2011 Dec 28
1
Subsetting a data frame vs. subsetting the columns
...ion(x) x[ord])) # user system elapsed # 0.022 0.008 0.029 What's going on? I realise this isn't quite a fair example because the second case makes a list not a data frame, but I thought it would be quick operation to turn a list into a data frame if you don't do any checking: list_to_df <- function(list) { n <- length(list[[1]]) structure(list, class = "data.frame", row.names = c(NA, -n)) } system.time(list_to_df(lapply(df, function(x) x[ord]))) # user system elapsed # 0.031 0.017 0.048 So I guess this is slow because it has to make a copy of...