无法打开文件“",原因是没有这样的文件或目录

无法打开文件“

问题描述:

我遇到了以下问题,在Rserve中的R中运行代码时,有时会发生 .到目前为止,我无法复制它.

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.

我首先使用

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

然后绘制数据:

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

我已经重新运行了这个程序,并调试了多次,一切正常.但是,有时在生产中会失败.目前,我怀疑是RServe还是文件系统.

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.

file.path在文件系统中的可移植性要比paste大,因为它会自动设置适当的目录分隔符.仅将paste(或paste0)用作文件名:

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:")