Plot() error when using REngine.Rserve - r

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.

Try this code :-
c.eval("dev.off()")

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.

Related

Accessing target of a windows shorcut

In linux machines, it is possible to access where a symbolic link is pointing to by using Sys.readlink function in R or readlink from the command line. Reading its documentation, we see that this is not intended for Windows shortcuts.
In Windows I have not been able to find a one liner to give me where the file points to. The closest I got was from this SO question that demonstrates the use of dir. While the output was not perfect I figured with some regex magic I could isolate the file path.
However when I tried system2('dir'), I received the error "dir" not found.
Is there (a better) way for me to access the file path of a Windows shortcut from R and why can't I use dir through a system call in R?
For anyone in the future finding this thread, the answer is fs::link_path() as pointed out by Edward Visel

How to close file connection in R after an error handle?

I have been using read.dbc function from read.dbc package and it is working fine for me.
Unfortunatelly, sometimes the file to be read is corrupted. To handle this, I use the try statement. The problem is that the corrupted file keeps "open" in R until I finish my R session, in a way I can't delete the file until the session is over.
My code is:
ReadFile <- try(read.dbc("C:/LocalPath/A_File.txt"))
Is there a way to "close" the connection prematurely (without the need to end the session)?
Also, I have tried to remove the variable with rm() and then cleaned the memory with gc() but the file keeps open.
More details: RStudio v0.99.484, R v3.3.1 (x64), OS Windows 7 Enterprise SP1
PS.: To reproduce the error simply try to read any file that is not a dbc file, a TXT file for example.
I don't think that this can be done in R as the file is locked from C code. If you look at the function dbc2dbf in this file you can see that it opens the file and tries to decompress it. Error "handling" is just printing the error and returning, but not closing the opened files which is bad practice imo. (Or a bug if you like to call it so.)
If you care you could open an issue on the github site of the project for this, maybe the author fixes the problem.
In case you are in desperate need (:P) of a working version I have compiled a quick fix for you that just calls fclose before it signals the error(s).
You can download it here. Just unpack and copy to your R library. Load with library(custom.read.dbc)

Couple of basic questions about Julia on Windows

I run Julia on Windows with the julia.bat file given in the zip archive. I have a couple of basic questions. This launches a DOS console.
When typing a plot() command Julia returns plot not defined. How to use the plot() function ? Is there a graphical interface available ?
When typing help I get:
What does it mean ?
There is also the launch-julia-webserver.bat file in the zip archive. When running this file two DOS windows open but nothing else happens. What can we do with this file and how ?
By the way I do not find any documentation answering such basic questions... of course if you know where to find such a documentation it would be an ideal answer.
To answer your immediate question, help is implemented as a function, and functions must be called with parentheses. Try help(), or to get help for a particular function in the standard library supply it as an argument; i.e., help(help).
When you enter a function name without the parentheses, the default is to print all of the implementations with their argument types.
The main Julia documentation is available online at http://docs.julialang.org/. We also have a mailing list at https://groups.google.com/forum/#!forum/julia-dev.
The webserver is pretty rough, especially on Windows. You should be able to open up http://localhost:2000/ with it running and access a web-based command environment. But you'll probably just want to stick to the normal command line.
Another contributor highlighted the response to help as a potential issue for new users and we've opened a bug on it at https://github.com/JuliaLang/julia/issues/1320. It's a new language and there's still plenty of rough edges, so thanks for helping us file those down!
To use launch-julia-webserver.bat, after you double-click it and the two DOS windows open, one of them should say "Connect to http://localhost:2000/ for the web REPL". If you open a web browser to http://localhost:2000/, you should be greeted with a welcome page that asks for your name and a session name.

XCode open file at error line for custom build script

I Apologize if this question has already been asked. i can't seem to find it anywhere if it has.
I have a custom build script use to syntax check some php files and upload them to a server, and this is executed as a part of the build process. since this script is used to parse inline php statements (embedded in objective c blocks using macros) it's fairly critical this script happens on each build. the actual execution is working fine, i'd just also like to be able to open a particular file when there is an error, and locate the cursor in the approximate location.
i have found that since xcode is configured on my system to open .php files by default (not sure if that's the norm or if i did it manually at some point), using
open filename.php
in a shell script opens the file.
i'd like to be able to specify the line number too.
eg something along the lines of
open filename.php --args --jump-to-line 1234
(--args is a switch for "open" meaning pass the arguments on to Xcode)
any ideas?
You can use the xed command. Only works for Xcode 3 though, not other editors. For Xcode 4, try this
See man xed

How do I get wkhtmltopdf running for a Drupal site on cPanel shared hosting?

First off, I will acknowledge that I am aware of another similar thread on the topic of wkhtmltopdf, but it was not similar enough to resolve my issue. Here's the other thread: wkhtmltopdf
Second, I will say that I have successfully used wkhtmltopdf with a Drupal site on a dedicated server that I run, where I installed the libX11 and used the most recent static version of wkhtmltopdf. That's on a CentOS 5 system and it runs nicely.
So, I have another hosting arrangement and I need to get the wkhtmltopdf to work, because it does the most amazing job producing bookmarked PDFs. The PDFs are beautiful.
The hosting is cPanel. I determined that it is on a server that has CentOS 5.5. It is not a problem to drop the static wkhtmltopdf in the print module's lib folder. However, I get the following message back in the Drupal admin status reports page (admin/reports/status).
It says,
"wkhtmltopdf library
The currently selected version of wkhtmltopdf () is not supported. Please update to a newer version."
I have obtained all of the needed .so files for CentOS 5, based on what jockie provided in his answer in the other StackOverflow thread.
Can someone knowledgeable confirm that his list was complete?
The idea of a shell script wrapper seems interesting and appears could be done for Drupal, if the naming of the shell script is called something like "wkhtmltopdf-wrapper.sh".
I have tried to use the shell script code that jockie provided, in a shell script. I did place all of the .so files in a sub-folder called "lib". I confess that I do not know what such things mean, in the script:
export HOME="$PWD"
Can someone interpret for me, what $PWD means?
export LD_LIBRARY_PATH="$PWD/lib/"
I understand that the script is going to get the .so files with that line, yes?
And can someone interpret the following line:
exec $# 2>/dev/null
What I am wondering is, where does the actual pdf get output? I did run the script. It did not throw any errors. However, I did not see a resulting PDF file.
Also, jockie's directions are not totally clear or defined enough. He says, "(some of them are symlinks)" under the list of .so files. Are such lines (in his list), the symlinks?:
lib/libX11.so.6 lib/libX11.so.6.2.0
Or am I mistaken? I was able to get all of them, so I don't know why they would be symlinks. The only thing is, that some of the versions are different. Do I need to delete the following files and make symlinks instead?:
lib/libX11.so.6
lib/libXau.so.6
lib/libxcb.so.1
lib/libXext.so.6
Should the shell script code be written differently, with Drupal in mind?
Thanks for reading and I hope someone can help!
...Finally, if anyone knows of a better solution, please share! Again, I appreciate the help!
...There does not seem to be a way, here on StackOverflow.com to notify jockie to check out this thread. I wish there was a way to write to them or notify them, so that they could clarify for them-self or contribute to this thread as well. If someone knows of a way, please let me know that too!

Resources