I have different csv files with different names. I want to make some calculations and after that I want to save the results into one csv file.
My data of two csv files have this format:
File 1:
 day                 price
 2000-12-01 00:00:00 2 
 2000-12-01 06:00:00 3 
 2000-12-01 12:00:00 NA 
 2000-12-01 18:00:00 3 
File 2:
 day                 price
 2000-12-01 00:00:00 12 
 2000-12-01 06:00:00 NA 
 2000-12-01 12:00:00 14 
 2000-12-01 18:00:00 13 
To read the files I use this:
file1 <- read.csv(path_for_file1, header=TRUE, sep=",")
file2 <- read.csv(path_for_file2, header=TRUE, sep=",")
An example of calculation process:
library(xts)
file1 <- na.locf(file1)
file2 <- na.locf(file2)
And save the results into a csv where the timestamp is the same for the csv files:
merg <- merge(x = file1, y = file2, by = "day", all = TRUE)
write.csv(merge,file='path.csv', row.names=FALSE)
To read multiple files I tried this. Any ideas how can make the process from 2 files to be for n files?
 
     
    