I have written a R code for a project. Since I have many data files, it is somewhat hard to rename the files everytime. Has anyone an idea to create a loop with R?
My code is (I is the number which has to be replaced by the loop):
data1 <- read_csv("../**I**_FILE.csv")
data2 <- read_excel("Nr**I**.xlsx")
#Merge
a <- function(s) (trunc(chron(s),"00:36:00"))
z1<- read.zoo(data1, header=TRUE, FUN=a, agg=mean)
z2<- read.zoo(data2, header=TRUE, FUN=a, agg=mean)
merged <- merge(z1,z2)
plot(merged$z2,merged$z1,
main="**I**")
*THIS PLOT HAS TO BE SAVED as "**I**.png/tiff/whatever"*
write.csv(merged, file="**I**.csv",
row.names = TRUE)