Reputation: 4524
I am setting up VSCode for R. Most of what I have right now works reasonably well. What still is a bit annoying to me is, that VSCode always opens a new window for a plot, if I make a change to it.
What I would like to do is:
I followed the instructions from Ken Run and also installed httpgd but could not make VSCode to do what I want.
Upvotes: 0
Views: 858
Reputation: 4524
The problem is that a .Rprofile
inside the project prevents a global one to be loaded.
It is also crucial to set the options right. With the following code in my project-.Rprofile
I could get what I want:
if (interactive() && Sys.getenv("RSTUDIO") == "") {
source(file.path(Sys.getenv(
if (.Platform$OS.type == "windows") "USERPROFILE" else "HOME"
), ".vscode-R", "init.R"))
if ("httpgd" %in% .packages(all.available = TRUE)) {
options(vsc.plot = FALSE, vsc.use_httpgd = FALSE)
options(device = function(...) {
httpgd::hgd(silent = TRUE)
.vsc.browser(httpgd::hgd_url(history = FALSE), viewer = FALSE)
})
}
}
Help came from here and REditorSupport. Thanks to @andycraig to point again to R Session Watcher.
Upvotes: 3