user12470302
user12470302

Reputation:

How to load multiple files in R?

I have three files I want to load in. They are all CSV's. I want to load all three files all at once into one combined dataframe. I want to do this so I don't have to go through three lines of loading in the files separately and then an additional line binding them all. I also want to save room in my Global Environment and having three dataframes loaded when I will combine them all into one will just take up room and make things confusing. I can click and view each dataframe separately but they aren't merged like I wanted them to be. How can I load in the files at once and merge them without reading each file one after another?

Upvotes: 0

Views: 138

Answers (1)

xwhitelight
xwhitelight

Reputation: 1579

Use purrr::map_dfr():

files <-  purrr::map_dfr(filelist, read.csv)

(All data frames have the same columns as my understanding.)

Upvotes: 1

Related Questions