vscode-R
vscode-R copied to clipboard
Interactive Notebook mode
First of all, thanks for making VSCode and R such a great partnership! R was the last thing I switched over to VSCode & it's great to be able to do everything in a single editor.
VSCode has a really nice feature where you can have a plain .py script file and mark jupyter notebook cells by # %%
: https://code.visualstudio.com/docs/python/jupyter-support-py. Then an interactive notebook opens up that displays output.
I'm not sure if this is an exposed API from VSCode, but if so, it would be fantastic to have the same capability for R.
Duplicate of #394, though outdated
@Tal500 This is actually a different feature. It takes # %%
code cells in plain R files (which the extension now well supports) and sends them to an interactive notebook. Think of it like a more powerful terminal where tables and figures are displayed inline.
Using IRkernel
, this should be possible. Here's an example (I had to manually run the cells via copy and paste).
The main things to wire up is:
- (1) starting an interactive window with the IRkernel and
- (2) running code in interactive notebook rather than the terminal.
The python version has these two settings:
-
"jupyter.interactiveWindow.creationMode": ["perFile", "single", "multiple"]
- Behavior of the Interactive Window. 'perFile' will create a new interactive window for every file that runs a cell. 'single' allows a single window. 'multiple' allows the creation of multiple.
-
"jupyter.interactiveWindow.textEditor.executeSelection": true/false
- When pressing shift+enter, send selected code in a Python file to the Jupyter interactive window as opposed to the Python terminal.
It seems like there is going to be a new API that makes sending commands to interactive window easier, so best to wait for that:
- Proposed API: https://github.com/microsoft/vscode-jupyter/pull/14676/
- Example usage: https://github.com/microsoft/vscode-extension-samples/pull/923/