R bind for multiple files

First, you need to get all the file locations, if your folder names follow some pattern you can specify it with a "regular expression".

list_of_files <- list.files(path = "C:/",
                            recursive = TRUE,
                            pattern = "pattern/.*\\.csv$",  # You need to replace this by a regular expression suitable for your particular application
                            full.names = TRUE)

Then you can read all the files in the list at once with something like this

df <- readr::read_csv(list_of_files, id = "file_name")

If you need more specific help, please provide a proper REPRoducible EXample (reprex) illustrating your issue.

1 Like