[R] [Rd] An issue happens Embed R and redirt png file

Rongrong dna_jin at hotmail.com
Thu Jun 5 12:14:54 CEST 2008


Thanks for your reply.

I use following coding to invoke R 2.7.0 process on Debian4:

        // argv[0] is my current work path
        char* av[] = {argv[0],"--silent","--no-save", "--gui=X11"};
        Rf_initialize_R(4, av);
        R_Interactive = FALSE;
        setup_Rmainloop();

I have installed latest gs, but still can get the error message:

Error in bitmap(file = "/tmp/test") : sorry, 'gs' cannot be found.



Rongrong wrote:
> 
> My R version is R 2.7.0, but the png still can not be used when I embed R
> in MyApp
> 
> 
> Dirk Eddelbuettel wrote:
>> 
>> 
>> 
>> Wrong list, so re-directing to r-help. Consider r-sig-debian for Debian
>> questions too, but subscribe or else your posts bounce.
>> 
>> On 4 June 2008 at 07:18, Rongrong wrote:
>> | 
>> | I am a new R user and I have a question of embedding R to generate png
>> | On Debian, I installed R by source code.
>> | 
>> | Now I want to embed R in an application which name is MyApp, and run
>> | the following syntax:
>> | png(filename="/tmp/Rplot%03d.png)
>> | example(rect)
>> | dev.off()
>> |  
>> | Unfortunately I get the following error message:
>> | 
>> | Error in X11(paste("png::", filename, sep = ""), width, height,
>> pointsize, 
>> | : 
>> |   unable to start device PNG 
>> | Calls: png 
>> | In addition: Warning message: 
>> | In png(filename = "/tmp/test%03d.png") : 
>> |   unable to open connection to X11 display ''
>> 
>> See the R FAQ.
>>  
>> | But I could run above syntax from R, and the result is correct, I can
>> get
>> | two png files from /tmp/ folder.
>> |   
>> | I try to respectively run same syntax(the syntax is:
>> | capabilities()[["png"]])
>> | under two modes, the result is different:
>> | In R the result is TRUE, but when MyApp embed R the result is FALSE
>> 
>> Because in case you have an x11 display, and in the other your don't. No
>> display, no x11.
>>  
>> | Then I used bitmap(file="/tmp/test") when embed R in MyApp, but get
>> another
>> | error message:
>> | 
>> | Error in bitmap(file = "/tmp/test") : sorry, 'gs' cannot be found
>> 
>> Fix that via 
>>     $ sudo apt-get install ghostscript
>>  
>> | Besides, I have installed xvfb. What I need do?
>> 
>> Almost there. Wrap your call to MyApp in svfb-run, ie do
>> 
>>     $ xvfb-run MyApp [other parameters]
>> 
>> and you get the virtual x11 device that png needs.   
>> 
>> R 2.7.0 should also alleviate the need for an x11 device due to its new
>> cairo-based device code.  While you didn't tell as which R version you
>> are
>> running, I suspect it is not the one the current one.
>> 
>> Dirk
>> 
>> -- 
>> Three out of two people have difficulties with fractions.
>> 
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Re%3A--Rd---An-issue-happens-Embed-R-and-redirt-png-file-tp17653928p17664791.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list