I'm not sure this is possible over the RStudio interface because of the way these graphical programs work. It's easy enough for RStudio to capture textual input and output for R. Capturing normal graphical output is pretty impressive, but that's done "natively" in R. Even packages like ggplot2
and lattice
use the builtin R plotting capabilities -- they do some rendering and data processing on their own, pass that onto grid
and then grid
renders the plots via R builtins when plot()
or print
is called (including implicitly in the REPL for interactive sessions). RCommander, RGL and the like use external libraries (Tcl/Tk, OpenGL), which render their interfaces directly over operating system services and not via R. R doesn't even see the output from these programs -- it only knows that the R wrapper function for these services hasn't returned yet. For local RStudio, this isn't a problem because the services are forwarded directly to the local display, but for RStudio server, there is no display!
Another consideration: assuming R could capture and forward X, that would imply having an X Server (in X, Server is the display/keyboard/etc, Client is the program that needs I/O) running in your browser. Modern JavaScript is pretty amazing at times, but X is a very complicated codebase and very sensitive to latency. Running X over the Internet is much slower than over the local network -- the protocol just wasn't designed for such things and most operations involve far too many roundtrips.
On a more practical side, you can still do most of your work via RStudio and only do the graphical commands via X forwarding:
- Do everything that doesn't involve an external graphics interface.
- Save your R Session (in the Environment tab or via the command line) as
.RData
in your project directory. (You can actually do this elsewhere, but it's generally more convenient if your workspace is saved in the working directory.) - Login in via SSH and X Forwarding and
cd
to the project directory. - Start R -- R will automatically load any existing workspaces saved as
.RData
. (You can disable this behavior with--vanilla
. Depending on the size of your workspace, R may take a few seconds to a few minutes to load. - Have fun with Rattle, Latticist, RCommander, RGL, etc! Be ready for massive lag if you're doing this over the Internet and not the local network (see above).