I try to unify files (whose names are 001.csv
, ..., 332.csv
) with the following for:
files.together<- function(directory,id=1:332) {
files<-list.files(path = directory,full.names = T)
values<-numeric()
for(i in id){
data<-read.csv(files[i])
values<-rbind(values,data)
}
write.csv(x = values,file = "data.csv")
data<-read.csv(file.path(getwd(),"data.csv"),header = T)
}
It works very well, except the last line, where what I'm trying to do is to automatically load the new unified file that has been created with the for