I have problems with saving files using looping. I first wrote a function which works well without loop. However, it always fail with loop. Can anybody tell me the reason?
a<-c(1,2,3)
b<-c(4,5,6)
c<-c(7,8,9)
data<-data.frame(a,b,c)
path<-list('path1/', 'path2/')
test<-function(data,path){
write.csv(data,file = paste0(path,'result.csv'))
}
purrr::walk(path, test(data=data, path=path))
# Warning in if (file == "") file <- stdout() else if (is.character(file)) { :
# the condition has length > 1 and only the first element will be used
# Error in file(file, ifelse(append, "a", "w")) :
# invalid 'description' argument