Things work when I write everything on one line:
mpg |> summarise(mean = mean(hwy), sd = sd(hwy))
However, when I write over multiple lines and highlight the code and press Ctrl + Enter or Alt + Enter e.g.
mpg |>
summarise(
mean = mean(hwy, na.rm = TRUE),
sd = sd(hwy, na.rm = TRUE)
)
VS Code should send the entire block to the terminal but instead I get this error:
r$> mpg |> summarise()
# A tibble: 1 x 0
r$> mean = mean(hwy, na.rm = TRUE),
Error: unexpected ',' in " mean = mean(hwy, na.rm = TRUE),"
r$> sd = sd(hwy, na.rm = TRUE)
Error: object 'hwy' not found
r$> )
Error: unexpected ')' in ")"
Running that same multi‑line block directly in the terminal works fine, so it looks like an issue with sending it to the terminal. Any thoughts on how to address this?
I'm using vs code 1.102.1, vscode-R 2.8.6, and R 4.5.1 on Windows 11. Settings below.
{
"r.rterm.windows": "C:/Users/malco/AppData/Roaming/Python/Python313/Scripts/radian.exe",
"code-runner.executorMap.r": "",
"r.lsp.formatting_style": "styler",
"r.alwaysUseActiveTerminal": true,
"r.bracketedPaste": true
}
Toggled "r.bracketedPaste" between true and false - error. Switched from radian to the plain R terminal - same error.
Here's the relevant part of my setup for VSCode:
Ctrl+Shift+P, Preferences: Open User Settings (JSON)
{
"r.rterm.windows": "${env:APPDATA}/Python/Python311/Scripts/radian.exe",
"r.rterm.option": ["--no-restore", "--no-save"],
"code-runner.executorMap.r": "",
"r.lsp.formatting_style": "styler",
"r.alwaysUseActiveTerminal": true,
"r.bracketedPaste": true,
"r.source.focus": "terminal",
"r.rterm.sendDelay": 8,
"r.sessionWatcher": true
}
This is in reference to this comment on GitHub for Sublime.
Preferences -> .Package Settings -> SendCode -> Settings
"r":
{
"bracketed_paste_mode": true,
"prog": "terminus",
}
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