I am repeating some tasks in R. I first read the csv file, do some repeating work, and write the csv file based on the date on the filename. I want to use for loop by using the filename pattern especially using day value (e.g. 17 in below example) say from 1 to 31. Could anyone help me how to code for loop here? Thanks in advance.
text <- read_csv("D://2017-10-17.csv")
... Some work here ...
write_csv(text , "2017-10-17_csv_backup.csv", na = "")
You could do
for (i in 1:31) {
text <- read_csv(paste0("D://2017-10-", i, ".csv"))
... Some work here ...
write_csv(text , paste0("2017-10-", i, "_csv_backup.csv"), na = "")
}