Cannot open file '', reason No such file or directory

隐身守侯 提交于 2019-12-20 06:39:12

问题


I've run into the following problem, which sometimes happens when running the code in R under Rserve. So far I was unable to replicate this.

I first create a PDF with

pdf(file=paste(output.dir, "/dates_",name,".pdf",sep=""),width=6.25,height=9,title="Breakdown Dates:")

and then plot the data:

plot(time, data1, xlab="", ylab="")

Most of the time it works, when it fails I get the error:

cannot open file '', reason No such file or directory

I've rerun this and debugged multiple times and all is working fine. However, sometimes in production it fails. Currently I suspect either the RServe or the file system perhaps.

Any ideas would be welcome.


回答1:


file.path is more portable across file systems than paste, as it automatically sets appropriate directory separators. Use paste (or paste0) for just the filename:

pdf(file=file.path(output.dir, paste0("dates_", name, ".pdf")), 
    width=6.25,height=9,title="Breakdown Dates:")


来源:https://stackoverflow.com/questions/16798605/cannot-open-file-reason-no-such-file-or-directory

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!