Reading in multiple csv files as data frames and concatenating (or row binding) them into one data frame is a task we routinely face.
In R, there are many ways of doing it. But which is the best, and why? I think the best way is the simplest and most high level way; something that is easy to read and write and edit. Here are three variants of what I think is the right way. The first is close to a base R way (except for the use of read_csv
and the beloved pipe),the second uses purrr
and dplyr
, and the third just uses purrr
.
library(readr)
library(tibble)
library(purrr)