Append multiple csv files into one file using R

前端 未结 4 1405
[愿得一人]
[愿得一人] 2020-12-20 06:54

I Have multiple csv files that i have already read into R. Now I want to append all these into one file. I tried few things but getting different errors. Can anyone please h

4条回答
  •  甜味超标
    2020-12-20 07:38

    How to import all files from a single folder at once and bind by row (e.g., same format for each file.)

    library(tidyverse)
    
     list.files(path = "location_of/data/folder_you_want/",
                  pattern="*.csv", 
                  full.names = T) %>% 
        map_df(~read_csv(.))
    

    If there is a file that you want to exclude then

    list.files(path = "location_of/data/folder_you_want/",
                  pattern="*.csv", 
                  full.names = T) %>% 
        .[ !grepl("data/folder/name_of_file_to_remove.csv",  .) ] %>%
        map_df(~read_csv(.))
    

提交回复
热议问题