I have multiple .txt file pairs that look something like this:
file1_a.txt
file1_b.txt
file2_a.txt
file2_b.txt
They contain information that I want to analyse further with a function I have created. In the script, I need to analyse each file pair together (linked together by "file1" and "file2").
How would you use a for loop (or apply-family) to loop over each file pair, running the function for each of them?
The question is not quite he same as the one found here, as I am looking to work with file pairs.
In dummy code:
files <- list.files(pattern = "*.txt")
for(file_pairs in files){
function(file1, file2)
}
The file_pairs part is what I am unsure about, as I do not know how to identify them and make it run on the files with similar name.