Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interactive Notebook mode #1412

Open
kylebutts opened this issue Aug 30, 2023 · 3 comments
Open

Interactive Notebook mode #1412

kylebutts opened this issue Aug 30, 2023 · 3 comments

Comments

@kylebutts
Copy link
Contributor

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.

image

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.

@Tal500
Copy link
Contributor

Tal500 commented Aug 31, 2023

Duplicate of #394, though outdated

@kylebutts
Copy link
Contributor Author

@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.

Example of Interactive Window and IRkernel

@kylebutts
Copy link
Contributor Author

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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants