8

Now I can use jupyter lab with R kernal in a web browser and use VS Code to edit jupyter note book code with python kernal, is it possible to edit R code in VS Code with jupyter notebook mode? Thanks for the comments and solutions.

Minyi Han
  • 807
  • 1
  • 8
  • 15
  • Does this answer your question? [Using jupyter R kernel with visual studio code](https://stackoverflow.com/questions/56497422/using-jupyter-r-kernel-with-visual-studio-code) – catastrophic-failure Sep 01 '22 at 08:51

2 Answers2

5

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" enter image description here

  • Click on the button right below ellipsis in upper right corner to choose kernel

    enter image description here

  • Switch to the desired kernel, in this case R's enter image description here

That's it!

testing_22
  • 2,340
  • 1
  • 12
  • 28
1

@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 failed way

Please run this syntax with VSCode terminal

install.packages('IRkernel')
IRkernel::installspec()

enter image description here

The rest is same, please restart VSCode and select "R" kernel from VSCode

Ichsan
  • 768
  • 8
  • 12