Difference between rbind() and bind_rows() in R

前端 未结 3 1038
盖世英雄少女心
盖世英雄少女心 2020-12-08 14:36

On the web,i found that rbind() is used to combine two data frames and the same task is performed by bind_rows()

3条回答
  •  爱一瞬间的悲伤
    2020-12-08 14:59

    Although bind_rows() is more functional in the sense that it will combine data frames with different numbers of columns (assigning NA to rows with those columns missing), if you are combining data frames with the same columns, I would recommend rbind().

    rbind() is much more computationally efficient in cases where the data you are combining are formatted the same way, and it simply throws an error when the number of columns is different. It will save you a lot of time for big data sets. I would highly recommend rbind() for these situations. Nonetheless, if your data has different columns, then you have to use bind_rows().

提交回复
热议问题