remoter icon indicating copy to clipboard operation
remoter copied to clipboard

[Question] Graphics with remoter

Open iagomez opened this issue 8 years ago • 8 comments

Remoter is great for running code in a remote server. How can I create graphs and have them display in my local R Studio window?

i.e

counts <- table(mtcars$gear)
barplot(counts, main="Car Distribution", xlab="Number of Gears")

iagomez avatar Oct 04 '16 13:10 iagomez

https://github.com/snoweye/user2016.demo may help.

snoweye avatar Oct 04 '16 20:10 snoweye

Thank you for the link @snoweye

Do you know if R needs some specific capabilities enabled for the graph to show up without using the s2c function?

The following still doesn't show the graphs on my R Studio window:

g1 <- ggplot(data=iris, aes(x=Sepal.Length, y=Sepal.Width, color=Species)) + geom_point(aes(shape = Species))
g1

But executing the following 2 lines does display the graph in the plots panel:

s2c(g1)
evalc(g1)

Again, thank you for your help!

iagomez avatar Oct 05 '16 17:10 iagomez

We had a bunch of changes over the summer, and it's quite likely that I messed something up during a merge. I'll take a look as soon as I can.

wrathematics avatar Oct 05 '16 17:10 wrathematics

Thank you @wrathematics

I'm using the remoter package from CRAN. Should I be using the github version instead?

iagomez avatar Oct 05 '16 19:10 iagomez

  • This version may still work well without s2c and evalc, but no guarantee.
  • The question is why you want to s2c that object g1 rather than the data creating g1 back to local?

snoweye avatar Oct 06 '16 00:10 snoweye

Thank you. I can try with that version.

Well, I was just trying different things to see if the image would show up. Ideally, I would like to write code that still runs if I'm not connected to a remoter::server Ideally without any s2c or evalc

iagomez avatar Oct 06 '16 13:10 iagomez

I get a plot in my RStudio session, but it is distorted.

Could I ask if it's possible to fix the distortion?

Here's what it looks like on my screen:

(Notice that the text is stretched horizontally)

library(ggplot2)
qplot(1:4, 1:4)

image

slowkow avatar Feb 14 '18 17:02 slowkow

  • Short answer long: resize the plotting window because it is plotted as a bitmap not regular plot/graph displayed at client window or save the plot in a pdf file and use s2c to bring the file back.
  • Median answer median: adjust the windows size before plotting the image and disallow resizing after that.
  • Long answer short: a callback function is not easy.

snoweye avatar Feb 15 '18 00:02 snoweye