Getting VsCode to work interactively with R
Step 1: Creating an ssh key to use VSCode
Setup VSCode to run on a compute node using instructions outlined here.
Step 2: ssh
to Biowulf and start an interactive session
ssh user@biowulf.nih.gov
Note
You will need to enter your ssh keyphrase that you created in step 1.
sinteractive --gres=lscratch:5 #don't forget to allocate lscratch space
Step 3: Set up the R Extension on VSCode
Once you have an sinteractive session and allocated compute node (e.g., CN1234), start VSCode and connect to the compute node. Install the "R Extension for Visual Studio Code".
Open the "R Extension" settings.
Add the following line below R › Rpath: Linux Path:
/home/$USER/bin/R #replace $USER with your biowulf username
Step 4: Set up Biowulf to work with VSCode R Extension
On Biowulf, create the file /home/$USER/bin/R
with the following content:
mkdir ~/bin
nano ~/bin/R
Paste the following into nano:
#! /bin/bash
module load R/4.2
exec R "$@"
Make /home/$USER/bin/R
executable:
chmod +x R
When R is called in vscode, /home/$USER/bin/R
will be called and the content will be run.
If you see an error regarding vscDebugger
not being found. You will need to install this package.
On Biowulf enter the following:
CN1234 $ module load R
CN1234 $ R
> remotes::install_github("ManuelHentschel/vscDebugger")
> q()
Step 5: Attach the VSCode R Extension
Assuming you are still connected to a computational node on VSCode, open a new .R file in VSCode. At the bottom of the page, you will see R: (not attached)
(See below).
To attach the R extension, simply click R: (not attached)
. That's it! The IDE should now be ready to use. You will be able to view figures and R object interactively as you work.