A quick piece of code that reads a text file, changes something, saves a new text file, and iterates that process for every text file in that folder.
setwd("path to the text files")
library(readr)
= Sys.glob("*.txt")
all_files
for(i in 1:length(all_files)){
= all_files[i]
data = read_file(paste(data))
mystring
= gsub("old piece of text", "new piece of text", mystring)
new_data
write_file(new_data, path = paste("something", code, ".txt", sep = "")
}
Bo\(^2\)m =)