1

I have a dataframe with many rows,one column is facor,I want to split the dataframe into list according to the factor column,How can I do it more efficiently?

library(microbenchmark)

size <- 1e7
set.seed(100)
df <- data.frame(
  V1 = factor(sample(100, size, replace = TRUE)),
  V2 = rnorm(size), v3 = rnorm(size)
)


microbenchmark(dfs <- split(df, df$V1))
Apai
  • 29
  • 3
  • I want to split a dataframe,but what is splitted in the two answer is a vector – Apai Feb 20 '19 at 11:40
  • Look also at this post: [R - split large dataframe into list in parallel](https://stackoverflow.com/questions/54312300/r-split-large-dataframe-into-list-in-parallel). Use `by` or `split` without factors. – Parfait Feb 20 '19 at 14:45

0 Answers0