0

I installed ReporteRs package on a remote linux server and try to generate HTML pages with it. It works fine, but when trying to add a ggplot to the document it gives this error:

(.:18048): Gtk-WARNING **: cannot open display:

I used the solution for these kinds of problems mentioned here, (running "export DISPLAY=:0.0", before running R), but there still is an error. Now it says:

(.:19674): Gtk-WARNING **: cannot open display: :0.0

Now I am wondering if there is a way to alter the addPlot() function in such a way that it doesn't want to display anything, but just wants to put it in the document?

I use the addplot() function like this:

data <- structure(list(x = c("1", "2", "3", "4", "5", "6", "7", "8", 
"9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", 
"20"), y = c(142, 316, 223, 319, 61, 155, 400, 384, 183, 342, 
308, 167, 20, 506, 310, 164, 66, 221, 368, 345)), .Names = c("x", 
"y"), row.names = c(NA, 20L), class = "data.frame")
library(ReporteRs)
library(ggplot2)

mydoc = bsdoc( title = 'My page' )
graph <-  qplot(data$x,data$y, data)
mydoc = addPlot( mydoc, fun = print, x =graph,vector.graphic = TRUE, width = 12,par.properties = parLeft(padding = 5)) 
writeDoc( mydoc, file = "/mypage.html" )

Is there a solution or work around for this problem? Many thanks in advance!

EDIT There is a work around. First I save the plot as an image with ggsave(). Second I use addImage() of the ReporteRs package to add this image to the document. This is rather ugly because it takes much more time to process.

EDIT2 I did some more investigation. It has something to do with X11 device. Now I am wondering how to use X11 without the need for displaying. Could this be possible with an R code?

6
  • Thanks for your response. I will not be the only one who will connect. I hope to find a solution in the ReporteRs code itself. Commented Jul 3, 2015 at 17:20
  • Yes I understand. Sorry for not being clearer, but we are trying to add the system to a web application and I was told that your solution is not the way to go. Commented Jul 3, 2015 at 17:45
  • The code you've posted works without error for me. I'm using Scientific Linux 6 with a connection over SSH and no DISPLAY set. This is with the current CRAN release of ReporteRs (0.7.8) and R 3.2.1. Commented Jul 3, 2015 at 22:55
  • Do you mean set the display like this "export DISPLAY=:0.0"? I use this linux Platform: x86_64-redhat-linux-gnu (64-bit) Commented Jul 4, 2015 at 5:07
  • I meant that on my remote server it works fine even without DISPLAY set. If you're still having trouble, one option if you have admin privileges on the box would be a dummy X driver per instructions at askubuntu.com/questions/453109/… . These would need adapting for other distros. Commented Jul 4, 2015 at 5:41

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.