I am trying to use VSCode after having used RStudio for a long time. I have multiple versions of R installed on my machine. Usually, I use the most recent version but occasionally I want to switch to use an older version. In R Studio, it is easy to change to a previous version but I cannot figure out how to change the version of R being used in VSCode.
You can access the language settings by clicking the language in the lower right hand corner of the window:

This will open language options in the command palette:

If you click "Configure 'R' language based settings...", settings.json will open. There should be a parameter already included called "r.rterm.windows". You can update this to point to the version of R you want to use. The next time you open a new terminal, it should use this setting.

View > Command Palette (Ctrl+Shift+P) > Preferences: Open User Settings (JSON)
and in there (file settings.json) change the paths for r.rpath.windows, r.lsp.path and --r-binary
Don't forget to add Rscript.exe to path: see here
My file settings.json is like below:
{
"window.zoomLevel": 1,
"[python]": {
"editor.formatOnType": true
},
"python.defaultInterpreterPath": "C:\\Users\\500596972\\AppData\\Local\\Programs\\Python\\Python310\\python.exe",
"security.workspace.trust.untrustedFiles": "open",
"workbench.colorTheme": "Default Dark+",
"terminal.integrated.enableMultiLinePasteWarning": false,
// R Options
"r.rterm.windows": "C:\\Users\\500596972\\AppData\\Local\\Programs\\Python\\Python310\\Scripts\\radian.exe",
"r.rpath.windows": "C:\\Program Files\\R\\R-4.4.0\\bin\\x64\\R.exe",
"r.lsp.path": "C:\\Program Files\\R\\R-4.4.0\\bin\\x64\\R.exe",
"r.lsp.debug": true,
"r.lsp.diagnostics": true,
"r.alwaysUseActiveTerminal": true,
"r.plot.useHttpgd": true,
"r.rterm.option": [
"--no-save",
"--no-restore",
"--r-binary=C:\\Program Files\\R\\R-4.4.0\\bin\\x64\\R.exe"
],
"r.bracketedPaste": true,
"r.sessionWatcher": true,
//
// Global Options
"files.defaultLanguage": "r",
"jupyter.interactiveWindow.creationMode": "perFile",
"jupyter.askForKernelRestart": false,
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With