- Install R if it is not already installed on your system.
- Install the R extension for VSCode
- Install XQuartz prior to installing the httpgd package.
- Install the following packages:
## start R
R
## Install packages to allow plot viewing
install.packages("httpgd")
install.packages("languageserver)
install.packages("lintr")
- Type
CMD + ,to open Settings. Typehttpgd. Check the option to use httpgd for R plot viewing:
- Also in Settings, type
rpath. Enter the following for macOS:
/usr/local/bin/R
- If you plan to use R Markdown documents, install Pandoc and install the following packages:
install.packages("rmarkdown")
install.packages("knitr")
- Add keybindings for arrow(<-) and pipe(|> or %>%) to your keybindings.json file.
Press
Cmd+Shift+Pto open the Command Palette. TypePreferences: Open Keyboard Shortcuts (JSON)and select it. Add the following blocks between the [ ] brackets:
// Insert pipe-operator
{
"description": "R Pipe Operator",
"key": "ctrl+shift+m",
"command": "type",
"args": {"text": " |> "},
"when": "editorTextFocus",
},
// Insert <- assignment
{
"description": "R Assignment Arrow",
"key": "alt+-",
"command": "type",
"args": {"text": " <- "},
"when": "editorTextFocus",
}
See here for other useful keybindings.
- Restart VSCode
- Connect via SSH
- Start an interactive session
sml
- Install the VSCode R extension here as well.
- In Settings, type
rpath. Enter the path to the lab R installation for linux:
/ref/dblab/software/spack-0.21.0/opt/spack/linux-rocky8-x86_64/gcc-8.5.0/r-4.3.0-3ggwaqrtfpe2t627qhwaknvsifz6dk5n/rlib/R/bin/R
Type R: Lib Paths and enter /ref/dblab/software/r-envs/4.1.3. Check the Use Renv Lib Path checkbox.
Type Terminal integrated profiles and update the settings.json for Linux. Add an entry for R.
{
"terminal.integrated.profiles.linux": {
"R": {
"path": "/bin/bash",
"args": ["-c", "eval `spack load --sh /3ggwaqr"]
}
}
}
- Install XQuartz prior to installing the httpgd package.
- Install the following packages:
## Start R
labr
runr
## Install packages to allow plot viewing
install.packages("httpgd")
install.packages("languageserver)
install.packages("lintr")
labr
runr
# Load the httpgd library
library(httpgd)
# Start the httpgd graphics device
hgd()
Copy the URL. Type R Plot: Open Httpgd URL and select it. Paste in the URL and press enter.
Open the Command Palette (Cmd+Shift+P).
Type R: Show Plot Viewer and select it to open the httpgd viewer.
Run a line by or selection using CMD + ENTER.
- Install R using spack (it has already been installed in the lab spack instance using the following commands):
spack create env r_430
spack install r@4.3.0 X=True
spack env activate r_430
spack add r@4.3.0 X=True
- Enter the following commands, replacing r@4.3.0 with your spec name:
spack location -i r@4.3.0
Add /rlib/R/bin/R to the path that is returned to get the path to the R executable. Update the rpath Linux setting with this path.
