【发布时间】:2022-01-21 15:57:30
【问题描述】:
我在使用循环保存文件时遇到问题。我首先写了一个没有循环的函数。但是,它总是因循环而失败。 谁能告诉我原因?
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
【问题讨论】: