Attempting to switch from R-Studio to VSCode in Windows. 2 questions:
- How do I allow R scripts in VS Code to send code to the R terminals in VS Code. I currently get the "command
r.executeInTerminal
not found". There's a screenshot of what that looks like here. - Am I using the wrong file path for radian?
Here are the exact steps I've taken so other rookies might be a little quicker than I was.
I installed the latest version of python (3.10.6; don't install from windows store, but from here), and R (4.2.1). I then installed radian using the following command following advice from here inside a Windows PowerShell terminal within VSCode:
py -m pip install -U radian
I then found the install path (following advice here) by typing, in the same place:
py -m pip show radian
Output: Location: c:\users\louis\appdata\local\programs\python\python310\lib\site-packages
In file explorer I copied the path into the search bar, moved to the radian folder, hit the copy path button in the top left, then added the path to the R settings page to my user settings (JSON), but it didn't work.
I decided to stop trying to use radian and keep the r.rterm.windows
directly to the R.exe
file path. I found this file path using the following in RStudio:
R.home("bin") # [1] "C:/PROGRA~1/R/R-42~1.1/bin/x64"
Note to the lost: You have to reverse the slashes to find the file in windows, so this for me was "C:\PROGRA~1\R\R-42~1.1\bin\x64".
You can then paste the file path into your file explorer and find the R.exe
file. I then was able to connect R to my VS Code terminal in the settings page, but scripts don't send information to the terminal. This means hitting ctrl+entr
with the cursor in the temp.R file leads to the message: "command r.executreInTerminal
not found".
There's a screenshot of what that looks like here.
My user settings (JSON) now look like this:
{
"python.defaultInterpreterPath": "C:\\Users\\louis\\AppData\\Local\\Programs\\Python\\Python310\\python.exe",
"files.associations": {
"*.rmd": "markdown"
},
// R Options
"r.rpath.windows": "C:\\Program Files\\R\\R-4.2.1\\bin\\R.exe",
"r.rterm.windows": "C:\\Program Files\\R\\R-4.2.1\\bin\\R.exe",
"r.terminalPath": "C:\\Program Files\\R\\R-4.2.1\\bin\\R.exe"
"r.lsp.path": "C:\\Program Files\\R\\R-4.2.1\\bin\\R.exe",
"r.lsp.debug": true,
"r.lsp.diagnostics": true,
"r.alwaysUseActiveTerminal": true,
"r.sessionWatcher": true,
"r.bracketedPaste": true,
}
Where's the error? Why don't the two panels talk to each other? Why is this like pulling teeth?