Reputation: 827
Now I can use JupyterLab with an R kernel in a web browser and use VS Code to edit Jupyter notebook code with a Python kernel. Is it possible to edit R code in VS Code using Jupyter notebook mode? Thanks for the comments and solutions.
Upvotes: 8
Views: 5081
Reputation: 1
these notes in addition to the response by another response were very helpful. if you are using this with R versions in conda environments, first create and activate the conda environment:
mamba activate myenv
mamba install -c conda-forge r-irkernel
mamba install jupyter
Run R while the environment is active:
IRkernel::installspec(name='r44_myenv', displayname='R 4.4.1 (myenv)')
Make sure you choose a unique name/displayname to avoid overlapping registrations.
You then follow the same steps above:
Select Kernel
in the top right.Select Another Kernel
>> Jupyter Kernel
>> R (myenv)
Hope that helps.
Upvotes: 0
Reputation: 828
@testing_22 it works with me too
just add some note from my experience
It will failed If you run IRkernel::installspec()
from RStudio or from Jupyter Conda environment
Please run this syntax with VSCode terminal
install.packages('IRkernel')
IRkernel::installspec()
The rest is same, please restart VSCode and select "R" kernel from VSCode
Upvotes: 1
Reputation: 2585
Yes, it is possible. You just have to install IRkernel (R kernel) first.
According to the docs, run both lines
install.packages('IRkernel')
IRkernel::installspec() # to register the kernel in the current R installation
Then, restart your VSCode and:
Type Ctrl + Shift + P to search for "Jupyter: Create New Blank Notebook"
Click on the button right below ellipsis in upper right corner to choose kernel
That's it!
Upvotes: 5