Using Linstat with RStudio

Doug Hemken

May 2019


In the SSCC we use our linux servers, collectively called linstat, to process large and computationally intensive tasks. Most users submit statistical jobs in "batch" mode, including R scripts, from the linux command prompt. See Using R on Linstat for more details on R batch/script processing options.

Most users develop their scripts on their own computers or on Winstat, often using a smaller subset of their data, and turn to linstat for their final analysis. It is also sometimes useful to start an interactive R session on linstat, to debug a script.

Using Rstudio, you can develop your R script on your own computer (or on Winstat), submit your finished script to linstat through a Terminal, and even debug your script on linstat, all from the same session.

This requires a recent version of RStudio (version 1.1 or higher).

Setting Up a Terminal Session

  1. If you are not on the SSC network (if you are not in the Social Science building, or not working on Winstat), VPN into our network.

  2. Start RStudio on your computer (or on Winstat).

  3. In RStudio's Terminal window (this is usually tabbed next to the Console), at the $ prompt type (substitute your own SSC user name):

    $ ssh -Y

    On a Windows 10 computer, try

    $ usr/bin/ssh -Y

    You will be prompted to give your password. Do that. You may have to ignore a firewall warning (Windows 10), or an RSA key warning (Winstat).

Batch or Script Processing

You now have a terminal session that you can use from within the RStudio interface. You can use this the way you would use any linux terminal. Submitting R jobs works as described in Using R on Linstat.

Working Interactively

To use R interactively from Rstudio, continue as follows.

  1. At the linstat prompt, start an interactive R session

    > R
  2. You are ready to send commands from RStudio to R on linstat. If you are working on a script in RStudio, highlight the code you want to execute, and use Ctrl-Alt-Enter to run the code on linstat.

Any data needs to be available on the linstat system (the V:/ and Z:/ drives from the Windows systems). Any packages you may need will also have to be installed on linstat.

When you are finished debugging your script, don't forget to quit() R, run a final "batch" version of your script from the linux prompt, and logout of linstat.

More instruction on how to interact with a terminal session can be found in the R and RStudio documentation

You should find you are able to send commands to linstat from your local RStudio session (this can be used for linux scripts as well as R scripts). And you can also copy the terminal results (the terminal buffer) back into your local Rstudio session, either through the GUI (click on the terminal name in the Terminal tab for a menu) of via a collection of terminal commands from the rstudioapi package: terminalList(), terminalBuffer(), etc.