This code will list csv files inside the directory
for each: import the csv (read.csv function)
add filename as a column and merge
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
library(plyr) library(readr) library(purrr) # add the path where the csv's are located setwd("./Downloads/test/") Tbl <- list.files(path = "./", pattern="*.csv", full.names = T) %>% map_df(function(x) read_csv(x, col_types = cols(.default = "c")) %>% mutate(filename=gsub(".csv","",basename(x)))) View(Tbl) |