2

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.

Datageek
  • 25,977
  • 6
  • 66
  • 70
  • The evidence piles up to suggest it is a Rserve issue: http://stackoverflow.com/questions/12417454/plot-error-when-using-rengine-rserve – Datageek May 29 '13 at 09:38

1 Answers1

2

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:")
Noam Ross
  • 5,969
  • 5
  • 24
  • 40
  • 1
    Good point, thanks Noam. I don't think this is the reason why this particular code fails though as it always runs on the same Linux machine. – Datageek May 29 '13 at 09:22