Reputation: 1088
I have a directory containing 70 other sub-directories with different CSV files. CSV files in each directory look like this Modified2-3.csv, added2_3.csv, Retired4_5.csv. My end result is to join all CSV starting with the name Modified but before that How can I loop through all subdirectories selecting only files starting with modified
I have tried this method but it says the character is zero
list.files(pattern = "^Modified.*name.csv")
I do want my result is a list of modified CSV looking like this Modified2_3.csv, Modified3_4.csv,Modified7_8.csv
Upvotes: 1
Views: 406
Reputation: 319
You should be able to go through them without a loop with the use of list.files()'s recursive argument.
list.files(pattern = "^Modified", recursive=TRUE)
Upvotes: 3