Reputation: 217
I have a list of files under 12 different folders, each file has the same name. For example, under folder_A there is a file called quant.txt, under folder_B there is also a file called quant.txt, and so on for other folders. All of these 12 folders are under the same directory.
How do I read/import the list of files from those 12 folders? Maybe something like lapply
or list.files
?
Upvotes: 1
Views: 185
Reputation: 3646
You can replace the the read function but I'm just going to use readLines
as a surrogate.
quantData <- purrr::map(list.dirs(), ~readLines(file.path(.x, "quant.txt"))
This iterates through your list of folders, reading the "quant.txt" from each
Upvotes: 1