VS Code as R IDE



VS Code can be dressed up as an R IDE with the balance of form an function you would expect

VS Code as an R IDE, because I do not like RStudio.

vscode-R provides R session support from inside VS Code.1 The home page for the integration is the vscode-R Wiki. Lots of nice conveniences, e.g. Interactive viewers and rmarkdown. support. There is deep integration of language internals (autocomplete etc) via R-languageserver client (which will eventually get merged into vscode-R apparently.) R needs the language server installed to deep language integration (step debugger etc) go. Although, TBH I haven’t found use for it yet. My use of R is more to generate reports than to create packages, though, so perhaps I am not the target audience.

install.packages("languageserver")

The corresponding extension is

ext install REditorSupport.r-lsp

Debugger support is via vscDebugger:

install.packages(c('R6', 'jsonlite'))
install.packages('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 Using httpgd in VSCode: A web-based SVG graphics device - Kun Ren’s Blog Posts, which also has some interesting insight into how plotting works in R more broadly.


  1. In some locations this is referred to as Ikuyadeu.r? AFAICT they are the same but there is renaming in-progress.↩︎


No comments yet. Why not leave one?

GitHub-flavored Markdown & a sane subset of HTML is supported.