Rendering Graphics with R using RConnect
3 posts
• Page 1 of 1
Rendering Graphics with R using RConnect
I have been using R from APL quite a bit but have rarely done any graphics via R.
The example graphics output in the R Interface Guide works fine.
I had a need to display a US map and chose the "usmap" and "ggplot2" packages. From R, both commandline and RStudio, these packages work fine and open graphics windows but I can't make it work via RConnect.
The simplest test is (in R):
> library(usmap); library(ggplot2); plot_usmap()
This will open a graphics window and show a US map.
If I execute the same via r.x from APL I get ... nothing.
⎕←r.x 'library(usmap); library(ggplot2);plot_usmap()'
gtools ggplot2 usmap stats graphics grDevices utils datasets methods
base
What am I missing?
The example graphics output in the R Interface Guide works fine.
I had a need to display a US map and chose the "usmap" and "ggplot2" packages. From R, both commandline and RStudio, these packages work fine and open graphics windows but I can't make it work via RConnect.
The simplest test is (in R):
> library(usmap); library(ggplot2); plot_usmap()
This will open a graphics window and show a US map.
If I execute the same via r.x from APL I get ... nothing.
⎕←r.x 'library(usmap); library(ggplot2);plot_usmap()'
gtools ggplot2 usmap stats graphics grDevices utils datasets methods
base
What am I missing?
- mhpcto
- Posts: 18
- Joined: Tue Sep 18, 2018 5:36 pm
Re: Rendering Graphics with R using RConnect
Hi mhpcto,
1) I have searched the internet, and found a suggestion about using the print method.
2) Our rscproxy does not seem to work with the latest R 4.2. For the future, we now recommend an interface to R called rsconnect that a customer Kimmo Linna wrote. You can get it on github. https://github.com/kimmolinna/rsconnect
I have put it in D:\git\rsconnect\ on my computer.
I did find that I needed to make the call twice to get the display to update, and I will log that as an issue.
Regards,
Vince
1) I have searched the internet, and found a suggestion about using the print method.
r.x'library(usmap)'
r.x'library(ggplot2)'
r.x 'print(plot_usmap())'
2) Our rscproxy does not seem to work with the latest R 4.2. For the future, we now recommend an interface to R called rsconnect that a customer Kimmo Linna wrote. You can get it on github. https://github.com/kimmolinna/rsconnect
I have put it in D:\git\rsconnect\ on my computer.
]load D:\git\rsconnect\rserve.dyalog
RS.start
r←⎕NEW #.RS.Rserve
r.eval 'library(usmap)'
r.eval 'library(ggplot2)'
r.eval 'print(plot_usmap())'
r.eval 'print(plot_usmap())'
I did find that I needed to make the call twice to get the display to update, and I will log that as an issue.
Regards,
Vince
- Vince|Dyalog
- Posts: 440
- Joined: Wed Oct 01, 2008 9:39 am
Re: Rendering Graphics with R using RConnect
Thanx for the input. Based on your response I did dive a little deeper into R plotting and how to render and save plots.
While plotting and viewing is kinda 1980's primitive (I have not found a way to pop up a graphics window that has controls for resizing, scaling, saving, etc. the way the RStudio graph window does) it seems to work with R 4.2 and rconnect. I will give the alternative a try.
Displaying graphs is working ok, but graph saving is a mess even in R native. I found that I can actually save a graph being displayed with 'dev.copy(svg, "myfile.svg") (many supported formats) but the file gets written only after I call 'dev.off()'!?!
While plotting and viewing is kinda 1980's primitive (I have not found a way to pop up a graphics window that has controls for resizing, scaling, saving, etc. the way the RStudio graph window does) it seems to work with R 4.2 and rconnect. I will give the alternative a try.
Displaying graphs is working ok, but graph saving is a mess even in R native. I found that I can actually save a graph being displayed with 'dev.copy(svg, "myfile.svg") (many supported formats) but the file gets written only after I call 'dev.off()'!?!
- mhpcto
- Posts: 18
- Joined: Tue Sep 18, 2018 5:36 pm
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group