We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.

Abhinav Joshi • 5 years ago

https://uploads.disquscdn.c... So I can start up radian as a terminal in vscode. However, when I press cmd+enter the code runs in the default R Interactive terminal rather than the python radian terminal. How would I go about making radian my default? I am new to vscode, so here is what my settings look like.

Kun Ren • 5 years ago

It looks like you set up radian as your default R terminal. Just remove r.rterm.mac and r.rterm.option to restore using R terminal by default.

Alberson Miranda • 5 years ago

I'm running into the same issue. Ctrl+Enter in Rmarkdown chunks runs in radian as expected, but with .R scripts it opens a new terminal. Am I doing something wrong here? https://uploads.disquscdn.c...

Kun Ren • 5 years ago

Are you using "R: Create R terminal" command to start radian or starting your own radian in the vscode terminal manually?

Alberson Miranda • 5 years ago

I use to start by clicking "Attach Active Terminal" below, which calls .vsc.attach(). Gonna try with command pallet and typing radian on shell

Kun Ren • 5 years ago

In this case, you need to set "r.alwaysUseActiveTerminal": true in vscode settings so that it won't try to start a session if it has not started one.

Alberson Miranda • 5 years ago
Alberson Miranda • 5 years ago

Found it! It was R Tools extension. Disabled it and now it works. Do you know that? I guess features are already covered by R and R LSP Client extensions

Kun Ren • 5 years ago

R Tools is another R extension. It might have some conflicts with vscode-R and vscode-r-lsp.

Shrek, Tan • 5 years ago

Looks fantastic! Thanks for sharing this!

Kyle Haynes • 5 years ago

Thanks - this is really useful

Sophie • 2 years ago

Hi, I realise this article is old but I was just wondering if it's possible to do this on a compute node? For me it works when I'm on a login node but not when I qrsh to a compute node. Thanks!

Ibrahim Saidi • 4 years ago

Nice article. How do you get plots to display within vscode itself? My plots are opening a new window. Thanks!

Kun Ren • 4 years ago

Could you confirm that you enabled "r.sessionWatcher" in vscode?

You might want to take a look at https://github.com/Ikuyadeu... and https://renkun.me/2020/06/1... for a nicer graphics device useful in vscode.

Ibrahim Saidi • 4 years ago

My "r.sessionWatcher" wasn't enabled. It's working fine now. Thanks.

Phoenix Mu • 4 years ago

Hi, thanks for this wonderful blog post. I tried to view a data frame in VS code but got this error:

Error in .External2(C_dataviewer, x, title) : unable to start data viewer
In addition: Warning message:
In View(smp.map) : unable to open display

I searched and found that pandas might be required, but I have pandas installed and the error persists. Do you have any idea how to solve this? Thanks in advance!

Kun Ren • 4 years ago

Looks like you did't enable r.sessionWatcher. You should set "r.sessionWatcher": true in vscode settings and reload vscode, then run command R: Create R terminal, and it should work then.

Phoenix Mu • 4 years ago

Yes that solves the problem, thanks!

Martin Bloemacher • 5 years ago

I am new to VS Code and try to set it up as you descibed.
For a regular *.r-file everything works fine. But for a *.rmd-file highlighting the code in chunk is missing and I can not sent a code line to the terminal. I am not sure what I am doing wrong.
It would be great, if you can help me out. I like your work and appreciate you efforts.

Here is my settings.json


// ========== begin: use R in VS code ===
"r.bracketedPaste": true,
"r.lsp.path": "/usr/local/bin/R",
"r.rmarkdown.enableCodeLens": true,
"editor.codeLens": true,
"r.lsp.debug": true,
"r.lsp.diagnostics": true,
"r.rterm.option": [
"--no-save",
"--no-restore",
"--r-binary=/usr/local/bin/R"
],
"r.alwaysUseActiveTerminal": true,
"r.sessionWatcher": true,
"r.rterm.mac": "/Library/Frameworks/Python.framework/Versions/3.6/bin/radian",
// ========== end: use R in VS code ===

Kun Ren • 5 years ago

You might need the following settings to associate .rmd with rmd language to make it work:



"files.associations": {
"*.rmd": "rmd"
}

Martin Bloemacher • 5 years ago

Thank you very much. Perfect.

Alberson Miranda • 5 years ago

Bro, is it possible to set plot size to match pane size as in RStudio? The only thing I miss right now is the "zoom viewer". Fixed size may be an issue when it affects some plot elements like arrows and annotations.

Kun Ren • 5 years ago

You may take a look at https://renkun.me/2020/06/1....

Alberson Miranda • 5 years ago

Duuuuuude, you're a life saver!

Mingxuan Liu • 5 years ago

Thanks for the post! How did you get the plot history out? This is really fantastic!

Kun Ren • 5 years ago

If you are using the default png-based plot, you could run vscode command (Ctrl + P or F1) Show Plot History.

If you use httpgd (https://github.com/nx10/htt... as described at https://renkun.me/2020/06/1..., then plot history navigation is supported on the web page.

Mingxuan Liu • 5 years ago

Thanks a lot!

John Coene • 5 years ago

非常好!Really amazing, thanks!

Sergey Kucheryavski • 5 years ago

Thanks for the post! How did you get your plots and View outcome inside the vscode? Everything works fine for me except this feature. Do you use XQuartz?

Kun Ren • 5 years ago

Please take a look at https://github.com/Ikuyadeu.... I'm constantly working on this feature and the latest doc is at https://github.com/renkun-k... which is not yet merged to master but you should follow this.

Sergey Kucheryavski • 5 years ago

Thanks a lot. It is a great extension, appreciate your work. I just tried the solution based on the session watcher. It works, however not exactly what I needed. I was hoping it would be possible to have the Quartz device window as one of the VSCode panel tab (so I can switch between plots, etc). But anyway, I think for most people the solution with PNG file preview will be good enough.

Kun Ren • 5 years ago

Please take a look at https://github.com/Ikuyadeu... and if you want to try it, please take a look at https://github.com/renkun-k... which provides testing builds that merges all my PRs in https://github.com/Ikuyadeu...

Sergey Kucheryavski • 5 years ago

Thanks!