0

Using the answer from here.

temp = list.files(pattern="*.csv")
for (i in 1:length(temp)) assign(temp[i], read.csv(temp[i]))

As the next step with a simple line, how is it possible to merge all read csv files/dataframes into one?

We suppose that all dataframes have the same column names.

Jaap
  • 81,064
  • 34
  • 182
  • 193
Kkyr
  • 55
  • 7
  • One of the [answers on that post](https://stackoverflow.com/a/40943207/5325862) uses `purrr::map_df`, which calls `bind_rows` across all data frames and returns a single data frame, I'm assuming how you want (can't say for sure without a [reproducible question](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example).) – camille Oct 01 '18 at 15:14

2 Answers2

1

I found the answer to this question on stackoverflow a while ago:

files <- list.files(pattern = "*.csv")
datalist = lapply(files, function(x)read.csv(x)) 
df = do.call("rbind", datalist) 
SmitM
  • 1,366
  • 1
  • 8
  • 14
  • 4
    If all you are doing is cutting and pasting another Stack Overflow answer, then you would do better to just mark the question duplicate and move on :-) – Tim Biegeleisen Oct 01 '18 at 15:18
0

We can use

library(tidyverse)
map_df(files, read_csv) 
akrun
  • 874,273
  • 37
  • 540
  • 662