I am trying to read a series of .tsv output files into the R environment into the same dataframe. However, each output file is in a different sub-folder but has the same name.
Example of file.tsv from Folder1
A B C
1 1 40
2 1 45
Example Paths:
A:/output/Folder1/file.tsv
A:/output/Folder2/file.tsv
A:/output/Folder3/file.tsv
The folder name holds important information, and I would like to preserve it in the aggregated dataframe.
Example:
A B C folder
1 1 40 Folder1
2 1 45 Folder1
3 1 50 Folder2
4 1 55 Folder2
5 1 60 Folder3
6 1 65 Folder3
I have found answers that allow you to read in and append .tsv files from different folders (Read several files in different directories in r), but I am getting stuck on how to add a column with the folder name. I have 395 unique folders so making the column by hand I only want to do as a last resort.
Thank you for any insight you might have!