2

I'm now work on a project which wants to use org.rosuda.REngine.Rserve to use facilities of R by C#. I have a particular problem that when I run the following code in C# client side:

c.eval("pdf(file=\"plots.pdf\", width=11, height=8.5)");
c.eval("plot(1,2)");

An error occour which said

Error in plot.new():cannot open file '', reason No such file or directory

But I checked that the file "plots.pdf" has already been created successfully by "pdf.." function. In R semantics, the successive plot() will output figure to the active device opened by the "pdf(...)" function, i.e. "plots.pdf" this time. But I'm very confused that why the error indicated that the file is ''. I use R-2.15.0 and Rserve-1.7.0 in linux server side. I'm eager to see your response. Thanks a lot.

fishfish311
  • 35
  • 1
  • 6
  • I've just run into the problem, which looks exactly the same. Was just wondering if you had any chance on progressing on it? – Datageek May 30 '13 at 10:19
  • 2
    I remember I solve this by restarting the Rserve engine and calling c.eval("dev.off()") each time after "pdf(...); plot(...)" statement. It seems that the error is caused by not closing the device correctly last time. If you still find some problem, you can try c.voidEval instead of c.eval. I found some r statement cannot run correctly in eval function. Hope my answer is helpful. – fishfish311 Jun 01 '13 at 14:41

2 Answers2

0

Try this code :-

c.eval("dev.off()")
unknown
  • 4,859
  • 10
  • 44
  • 62
0

A folder named (null).1001.1001


Related answer at Cannot open file '', reason No such file or directory suggests using file.path as a alternative to paste for creating filenames with platform-independent path separators.

Comments suggest dev.off(). I had better luck with graphics.off(). The difference is that dev.close() closes the current device, graphics.off() closes all open devices.

But my solution turned out to be https://askubuntu.com/questions/721485/what-is-folder-null-1001-1001 I found a mysterious folder named (null).1001.1001 (Rserve is running as uid 1001, gid 1001 on Linux). I create this folder at the start of my session and I'm good to go. The presence of this folder seems to help in my case, but I don't know (yet!) what that folder is.

Community
  • 1
  • 1
woodvi
  • 1,898
  • 21
  • 27