What is the most efficient way to cast a list as a data frame?

前端 未结 7 873
悲&欢浪女
悲&欢浪女 2020-11-29 16:55

Very often I want to convert a list wherein each index has identical element types to a data frame. For example, I may have a list:

> my.list
[[1]]
[[1]]         


        
7条回答
  •  醉酒成梦
    2020-11-29 17:34

    The dplyr package's bind_rows is efficient.

    one <- mtcars[1:4, ]
    two <- mtcars[11:14, ]
    system.time(dplyr::bind_rows(one, two))
       user  system elapsed 
      0.001   0.000   0.001 
    

提交回复
热议问题