Using R on VSCode Remotely

Analyzing SNP data remotely on a server for demultiplexing, etc. can be a bit of a hastle if you would like to do some R analyses. Here is how I set up VSCode to run on my office machine (& laptop) and interface with our servers where all the data are analyzed. I would love to have RStudio be able to do this but, alas, it is not possible yet.

Published

February 20, 2023

Seting up R and VSCode

First of all, we’ll need to install some stuff on the R side. The language serve is necessary for VSCode and the httpgd is helpful for viewing graphical output. The following code will check to see if you have them installed and if not, install them for you.

if( !require(languageserver) ) { 
  install.packages("languageserver")
}
Loading required package: languageserver
if( !require(httpgd)) { 
  remotes::install_github("nx10/httpgd")
}
Loading required package: httpgd

Now, download VSCode from the main server. You will also need to install the R Extension for Visual Studio Code, which can be installed from inside VSCode.

Now, you’ll need to install the following items for VSCode:

Once you have this set up, it is a pretty stratight forward exercise to follow VSCode prompts to get to work. For me, after logging into the remot server, I created an R file and basically followed the instructions given by VSCode on what needed to be instlled on the server instance side. It was all locally done so no big deal.

The only problem that I did run into is that for some reason, jsonlite would not install because of some python dependency problem.

Failed to get list of R functions. Make sure that `jsonlite` is installed and r.rpath.linux points to a valid R executable.