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

tiagocc • 6 years ago

Thanks for the recommendations.

I myself have started to migrate all my work to vscode from RStudio for similar reasons as yours and I really like it!

Kun Ren • 6 years ago

I've been constantly working on vscode-R and languageserver to make VSCode a better editor for R. If you encounter any problem on code editing features (completion, definition, etc.) please file an issue at https://github.com/REditorS.... for problem interacting with R session, at https://github.com/Ikuyadeu....

lals101 • 5 years ago

great thanks, where does one store/put the `~/.lintr`file?

Jim Melichar • 5 years ago

How do you get Radian set as the default terminal in Windows? That's the piece I'm missing, but this walkthrough has been great.

https://uploads.disquscdn.c...

Kun Ren • 5 years ago

In Windows, please go to VSCode settings, and set up the following entries:


{

"r.rterm.windows": "C:\\Users\\ken\\AppData\\Roaming\\Python\\Python38\\Scripts\\radian.exe",
"r.rterm.option": []
}

You need to modify the path to radian according to your installation and ensure the rterm options are removed.

Emre Gonulates • 5 years ago

For the folks who are new to VSCode: in settings, search for "settings.json":

https://uploads.disquscdn.c...

In my computer, radian.exe was in "Program Files". Here is the final setup looks like:

https://uploads.disquscdn.c...

Jakez Rolland • 3 years ago

Hi,

I can't ctrl+click on a function I created that is in a closed file even if this file has been sourced in the R session. This is really frustrating, is there a way ?

It works with function in a package, or if the file is open.

Thank you

Russell • 3 years ago

Is there a way to publish to RStudio Connect from VS Code?

Arun Frey • 4 years ago

Hi Kun Ren, thanks for writing this informative blog post, it really helped me set things up.

Two remaining questions from having used R with VSCode for the past few weeks:

* object environment: By far the biggest thing I miss about RStudio is the environment viewer, which shows all loaded objects and updates in real time. I have bee getting around this issue with View() and View(globalenv()), but it doesn't automatically update once new objects are loaded. Am Is there a better way to do this?

* html viewer: when I generate html tables, they currently open in my default browser. Is there a way of viewing these directly from within R, akin to the Viewer tab in RStudio? When I try, I get the following error: VSCode WebView has restricted access to local file.

Thanks again for your help in setting this up.

Kun Ren • 4 years ago

As for the environment pane, the latest vscode-R already supports this via https://github.com/Ikuyadeu....

As for the html viewer, would you like to share a minimal code example you think should trigger a vscode webview tab? I recommend that you go to https://github.com/Ikuyadeu... and file an issue there.

Jose Manuel Vera • 5 years ago

love it. Apart of Radian (installed but unable to run it or find it) all the rest worked ok. thanks

Kun Ren • 4 years ago

It would be nice if you could file an issue at https://github.com/randy3k/....

Ofek Shilon • 5 years ago

Thanks for the writeup! Are you able to have a remote R session in VS code, as in RStudio server? If so - how?

Kun Ren • 5 years ago
lals101 • 5 years ago

Hi There,

Thank you very much for this, it is super efficient.

In VS Code on a Mac, how does one edit the length_line_linter options?

At the moment I've lines greater than 80 characters and the entire line gets highlighted with a wavy line underneath. Is there a way to change this within the VS code settings?

Kun Ren • 5 years ago

You may take a look at https://github.com/jimheste.... Briefly, you could create a `~/.lintr` file with the following content:

linters: with_defaults(line_length_linter(120))

Remember to leave a new line at the bottom of the file.

lals101 • 5 years ago

great thanks, where does one store/put the `~/.lintr`file?

Hoang Nguyen • 5 years ago

Hi there
R in VScode is great. However, I find it difficult to manipulate data in vscode with R. E.g. it's easy to use $ to access some layers of data in Rstudio but this feature seems to be not available yet in VScode.
Cheers
Hoang

Arnaud MarĂ©chal • 5 years ago

Hi, thanks for the great tuto. I understand that .Rmd format is not currently supported by VS code, is that correct?
Any alternative ?
Thanks

Kun Ren • 5 years ago

Rmd is supported in VSCode but running Rmd is not as good as RStudio at the moment. Highlighing code chunks (https://github.com/Ikuyadeu... and sending chunk to terminal (https://github.com/Ikuyadeu... are not implemented yet.

Issac Lee • 5 years ago

thank you for the document! I have been searching for the R env from other platform! This is great!

apricot • 5 years ago

Great article. One question is, can we let it auto-format the document on save like ESLint does?

Kun Ren • 5 years ago

It could be enabled by `editor.formatOnSave` in vscode settings. As language server relies on styler package to format the document which is quite slow for long script, I personally disable it in my settings.

David Gray Lassiter • 5 years ago

Very cool. I've gotten most of this to work, but the outline portion seems to fail completely.

I only get things to show up in the outline if I include 4 asterisks after.

# This shows up ####

# This does not show up

Also, the code folding works based on indentation, but not based on using asterisks to identify sections/subsections.

Tips?

David Gray Lassiter • 5 years ago

Thanks for answering me on Github, :).

For others looking at the same problems:
The demo uses .Rmd files to show how sections are used to populate the outline. I missed that. Of course .R files won't work the same since # is used to make comments in R whereas it is used to form an outline in Markdown.

Mark • 5 years ago

A really useful feature in Rstudio is the data viewer with View(), especially for complex objects. Is something like this possible?

Kun Ren • 5 years ago

At the moment, we don't have the View() that could turn a complex object to a nice interactive table with expandable items but I think it is perfectly possible that we could implement this at some point. Would you like to file an issue to request this feature at https://github.com/Ikuyadeu...

Arun • 5 years ago

Hi, this has been very useful, thank you! How does the VSCode editor handle %>% pipes? I have been writing Python and R code in Atom, but the formatting doesn't take pipes into account which has been very frustrating.

Kun Ren • 5 years ago

I have done some work in languageserver to make on-type-formatting work with pipes (in fact, any operator that does not end an expression). https://github.com/REditorS...

I'm not sure if works well in Atom but here in VSCode it works not bad.

Alban • 4 years ago

I have also had a question about this, and am fairly new to coding so cannot yet wrap my head around the various pull requests above. I have installed the R and R LSP extensions, but when writing a pipe and pressing enter, the code still jumps to the next line, without adding the indentation.


mtcars %>%
head()

as opposed to


mtcars %>%
head()

Alban • 4 years ago

I just saw the code did not render properly. The desired output I am looking for is:
mtcars %>%
\tab head()

zerodel • 5 years ago

Hello, thanks for this informative article. I tried this cool light weight tool combination,

still a question, is there a equivalent method for "refactor"? such as extract variable or extract function in Rstudio?

Kun Ren • 5 years ago

We don't have it at the moment. Maybe we'll take a closer look at refactor and implement it in languageserver as a CodeAction in VSCode.

Bruce Chen • 5 years ago

What about debug?It seems that r extension does not support it right now

jbl • 5 years ago

Same issue, so browser the best way ? Kun Ren , any updates on this ?

Kun Ren • 5 years ago

There's some nice pioneer work at https://github.com/Ikuyadeu.... We'll take a closer look at how we could make everything work together more smoothly.

Campo • 5 years ago

Hi there, I'm having some problems to set the color text as you have in you article.

Could you help me please? I would really appreciate it.

Kun Ren • 5 years ago

If I understand it correctly, "the color text" you mean the radian terminal? You might want to take a look at the wiki at https://github.com/Ikuyadeu... about the installation.

Kyle Haynes • 6 years ago

thanks - really useful. VSCode is a really awesome editor, my only gripe is the slowness of (Windows?) console printing so slowly. Wondering if this is a gripe for you?

Kun Ren • 6 years ago

Looks like https://github.com/Ikuyadeu..., on Linux and macOS we no longer have this problem, on Windows we might need more investigation on it.