Rendering Graphics with R using RConnect

Using Dyalog under 'nixes

Rendering Graphics with R using RConnect

Postby mhpcto on Fri Aug 05, 2022 11:31 pm

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?
mhpcto
 
Posts: 15
Joined: Tue Sep 18, 2018 5:36 pm

Re: Rendering Graphics with R using RConnect

Postby Vince|Dyalog on Mon Aug 08, 2022 1:20 pm

Hi mhpcto,

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: 374
Joined: Wed Oct 01, 2008 9:39 am


Return to UNIX and Linux

Who is online

Users browsing this forum: No registered users and 1 guest