You can associate a Console panel and kernel with a text editor in JupyterLab, and use it to execute selected code, RStudio style.
- Create or open a text source file in JupyterLab.
- Right click in the text editor panel.
- Click Create Console for Editor.
- Select a kernel matched to the programming language you want to execute in the file.
- Notice the Console panel that appears.
- Highlight one or more lines back in the text editor you'd like to run.