Vscode-r: Preview of Rmarkdown

Created on 23 Mar 2019  路  11Comments  路  Source: Ikuyadeu/vscode-R

Currently, the Markdown file can get a preview.
I believe R markdown file can also get a preview by calling preview command on Markdown.
I put this issue as the TODO

feature-request

Most helpful comment

With #150, we can use rmarkdown::run(file) to start an HTTP server to show an RMarkdown document, instantly.

All 11 comments

By adding the below to settings.json, you can use Markdown: Open Preview on R markdown files. It doesn't do anything special with the R code blocks, though.

"files.associations": {
     "*.Rmd": "markdown"
}

From https://qiita.com/yutannihilation/items/1f71c0fedae6e4b8038c

@andycraig Thank you! It is working well.

I can not use R markdown syntax and inline execution by this change.
We should call Markdown: Open Preview as the R markdown mode.

That's right, that change doesn't do anything special with R code blocks.

A better R markdown experience could be gained by adding a command that calls the knitr package, and then previews a resulting HTML or PDF file (maybe using https://marketplace.visualstudio.com/items?itemName=hdg.live-html-previewer and https://marketplace.visualstudio.com/items?itemName=tomoki1207.pdf). This could be a Good First Issue.

RStudio-like inline output from R code blocks would be tougher. I'm not sure if the VSCode editor supports non-text objects.

It looks like the neuron extension might be very helpful here:

https://marketplace.visualstudio.com/items?itemName=neuron.neuron-IPE

I haven't managed to get it running successfully yet though, and it sounds like others are having trouble too: https://github.com/neuron-team/vscode-ipe/issues/187

I've had more success with this fork:
https://marketplace.visualstudio.com/items?itemName=pavan.VSNotebooksBeta
It connects to Jupyter and displays the output of R code sent to it.

Using VSNotebooks:

notebook

This setting was necessary to get VSNotebooks to recognise Rmd files:

"files.associations": {
    "*.Rmd": "r"
}

Is this still being worked on? Rmarkdown support is one of the major reasons I don't switch to vscode.

Hi @rjBadger, as shown in the video above, the VSNotebooksBeta extension (a fork of the neuron extension) provides some support of R Markdown files, although there is a lot of room for improvement. I'd like to see work on R Markdown support for VSCode made on neuron or one of its forks, so that the improvements also benefit Julia etc. I'm not currently working on anything related to this, though.

There is an issue open for adding support for other languages to the (very good) Jupyter component of the Python extension. If you are interested in better notebook support for R, please consider voting for it here: https://github.com/microsoft/vscode-python/issues/5078#issuecomment-507751659

Thank you!

With #150, we can use rmarkdown::run(file) to start an HTTP server to show an RMarkdown document, instantly.

That sounds great @renkun-ken! Would this also allow to show chunks of text, math, and or code separately? For an illustration of what I mean, see the GIF below:

vscode-shiny-rmd

Was this page helpful?
0 / 5 - 0 ratings

Related issues

albert-ying picture albert-ying  路  5Comments

gcambray picture gcambray  路  4Comments

ShortArrow picture ShortArrow  路  4Comments

Victsz picture Victsz  路  5Comments

nathaneastwood picture nathaneastwood  路  6Comments