VS Code as R IDE
October 5, 2021 — August 22, 2021
Suspiciously similar content
VS Code as an R IDE, because I do not like RStudio.
vscode-R provides R session support inside VS Code. The home page for the integration is the vscode-R Wiki. There are lots of nice conveniences, like Interactive viewers and RMarkdown support. R needs the language server installed for deep language integration (step debugger etc) to work. Although, to be honest, I haven’t found much use for it yet. I use R more to generate reports than to create packages, so I might not be the target audience.
The corresponding extension is
Debugger support is via vscDebugger:
The following config in settings.json
is helpful for keeping it fast with R development, since it ignores blogdown cruft and miscellaneous R packaging stuff.
"files.watcherExclude": {
"**/env/**": true,
"**/output/**": true,
"**/renv/**": true
},
"search.useGlobalIgnoreFiles": true,
"files.exclude": {
"content/**/*.html": true
},
"search.exclude": {
"content/**/*.bib": true,
"content/**/*.yaml": true
},
"cSpell.enableFiletypes": [
"rmarkdown",
"rmd"
],
For editing blogdown, an in-app browser preview can be useful.
Plotting runs a tame webserver, httpgd: Asynchronous HTTP server graphics device for R:
install.packages("httpgd")
hgd()
hgd_browse()
x = seq(0, 3 * pi, by = 0.1)
plot(x, sin(x), type = "l")
dev.off()
For philosophy, see Kun Ren’s post, Using httpgd in VSCode: A web-based SVG graphics device, which also explains how plotting works in R more broadly.
1 Positron
Positron is a VS Code fork specialising in R-friendly experiences with some enhancements.
How is Positron different from RStudio, VS Code, or Jupyter notebooks?
- Positron has first-class, built-in support for R and/or Python via an integrated Console, with extensibility options for other languages in the future. This native support includes specialised views and panes throughout Positron such as a Data Explorer, Connections Pane, Variables Pane, and more.
- Positron runs the interpreter separately from the IDE, so unlike in RStudio a crash in R/Python won’t always crash the IDE. It also means that you can swap between versions of your preferred language on the fly without a full reload of the IDE, just the integrated console.
- Positron supports VS Code compatible extensions (
.vsix
files), providing extensibility of capabilities beyond the core IDE itself. By building on Code OSS, Positron gets rich text editor capabilities and access to thousands of community extensions out of the box. Read more about using extensions with Positron.- Positron is deeply focused on native data science workflows; it provides a batteries-included and cohesive experience beyond that of a general-purpose IDE or text editor such as VS Code.
posit-dev/positron: Positron, a next-generation data science IDE