Using jupyter R kernel with visual studio code - r

For python jupyter notebooks I am currently using VSCode python extension. However I cannot find any way to use alternative kernels. I am interested in jupyter R kernel in particular.
Is there any way to work with jupyter notebooks using R kernel in VSCode?

Yes, it is possible. It just requires an additional configuration to connect with the R kernel in VSCode.
It's worth noting that, if you prefer, you can use the notebook in VSCode Insiders where there is native support for notebooks in many languages, including R.
If you're using Jupyter in VSCode, firstly install IRkernel (R kernel).
According to the docs, run both lines to perform the installation:
install.packages('IRkernel')
IRkernel::installspec() # to register the kernel in the current R installation
Now, you should:
Reload Window Ctrl + R
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
Switch to the desired kernel, in this case, R's
That's it!

Agreed with #essicolo, if you are 100% stuck on using vscode this is a no-go.
[About kernels] Sorry, but as of right now this feature is only supported with Python. We are looking at supporting other languages in the future.
Yeah, that's the case for now, even if you start an external server. I hate having to say that, as we really want to support more of the various language kernels. But we started out with a Python focus and we still are pretty locked into that for the near future. Polyglot support is coming, but it won't be right away
per Microsoft Employee IanMatthewHuff
https://github.com/microsoft/vscode-python/issues/5109#issuecomment-480097310
preface - based on the phrasing of your question, I am making the assumption that you are trying to perform IRkernel in-line execution from your text ide without having to use a jupyter notebook / jupyterlab.
That said, if you're willing to go to the dark side, there might be some alternatives:
nteract's Hydrogen kernel for Atom IDE - the only text ide that I'm aware of that still supports execution against IRkernel. I know, I know - it's not vscode but it's as close as you'll probably get for now.
TwoSigma's Beaker notebook - it's been a lonngggg time for me but this a branch of jupyter that used to support polyglot editing, I'm not sure if that's still supported and it seems like you aren't that interested in notebooks anyway.

#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()
The rest is same, please restart VSCode and select "R" kernel from VSCode

Related

WebIO is not being detected by Jupyter Notebook

I am trying to open a Jupyter Notebook file in classic Jupyter Notebook interface. I am attempting to create an interective app that uses Julia programming language in interactive codes. For that I am trying to use the Interact library, because I know it features things such as buttons, sliders, etc. It requires the WebIo extension to be installed. However, from what I have experienced so far, Jupyter notebook does not detect the WebIO extension.
I tried following the instructions at https://juliagizmos.github.io/WebIO.jl/stable/gettingstarted/ and at https://juliagizmos.github.io/WebIO.jl/stable/troubleshooting/not-detected/. In the last link I found that another extension needed to be install and I found more information in this link (https://juliagizmos.github.io/WebIO.jl/latest/providers/ijulia/). I tried executing this command in my Windows prompt and it had apperently been succesful. When executing the command suggested at the second link, I got an error in the Julia REPL saying that WebIO extension for Jupyter Lab must be installed through Python or Conda, which I had already done.
I am also a bit confused as to how I can check to see if the extension is enabled.
I believe the problem has to do either with the installation of IJulia or the pip installation of WebIO. I rarely use pip, so I don't know if I did it correctly.
Thank you.

Differences between various consoles in Python

I am trying to make run a script for webscraping. However, I feel the problem could be that I keep running the written script in the wrong console.
So far I could not really understand the differences between the consoles cmd and Anaconda Prompt. Anaconda Navigator looks rather like an administrative tool, but it seems still to make a difference for my code whether I use a terminal from there or not. Could anyone elaborate on that?
Much appreciated
cmd: command-prompt, that used to run our python script, especially for scripts with .py extension. Besides that, we can used to install python library
Anaconda Prompt: almost similar to cmd. But usually we used to open jupyter notebook or other console on Anaconda Navigator.
Anaconda Navigator: a GUI desktop application that is included in the Anaconda installation package. Through Anaconda Navigator, programmers can easily run and manage Conda packages, environments and channels without the need to use command prompt commands. Anaconda Navigator can search for packages in the anaconda cloud repository.
So, the difference depends on what we want to do. You can't judge the problem arises because of the wrong console. It depends on the error message that appears.
Suggestion: read the error message, and analyze or find a way to solve the problem

Jupyter MathJax Physics package

MathJax3 includes a port of the physics package, which I would like to use inside jupyter notebook / lab.
What are the steps necessary to use this extension? Can it be done without writing custom config files (important for collaboration)?
I tried installing the MathJax3 renderer for jupyter, but it seems that it does not recognize the \require command used to enable the extension. Another user already formulated an issue on github in September, but with no answers yet unfortunately.

JuliaPro: import Jupiter notebook

I usually use Jupyter to have my interactive environment with Julia, now I am switching to JuliaPro, as they claim it is the fastest and easiest way of Julia programming. But, I cannot upload my .ipynb notebooks on JuliaPro. Are they compatible with each other? How can I work with my notebooks on JuliaPro? Thanks!
As was explained in the comments, the .ipynb file format was designed to be rendered in a browser, while Juno/Atom is a text editor that expects a plain text file for display. In general therefore you wouldn't be able to directly use an .ipynb file in Juno.
There is however an option to convert your notebooks to .jl scripts, which is exactly what Juno is expecting: in your Jupyter notebook click on File > Download as > Julia (.jl) (see below)
There's also an answer here that discusses a command line option if you need to batch convert a lot of files.
Also note that your choice of editor / programming environment is unrelated to the version of Julia you're using - while JuliaPro ships with Juno as standard (or potentially the Julia VS Code extension in future), nothing's keeping you from just doing using Pkg; Pkg.add("IJulia"); using IJulia; notebook() in your JuliaPro installation and continuing to work on your notebooks in Jupyter.

Advice on upgrading Emacs (22 -> 24), and also about GUI vs console/terminal

I'm using a Macbook Pro (Snow Leopard, 10.6.8) and have been a regular emacs user for the past few months. I'm trying to install a modified version of Emacs 24.2 provided here to utilize Emacs Speaks Statistics (ESS) from the downloads page. I currently have 22.1.1:
M-x emacs-version
GNU Emacs 22.1.1 (mac-apple-darwin) of 2011-06-07 on b1030.apple.com
I installed the emacs linked earlier, put it in Applications, and set this in .bashrc:
alias emacs="/Applications/Emacs.app/Contents/MacOS/Emacs -nw"
So it seems like it's working correctly as I wrote and successfully ran a short R program.
M-x emacs-version
GNU Emacs 24.2.1 (x86_64-apple-darwin, NS apple-appkit-1038.36) of 2012-08-27 on bob.porkrind.org
Is this the usual way to upgrade to a "newer version" of Emacs? Sorry if this question seems trivial, but I've never done this before (I typically used emacs on a different computer) and the Installation step on the previous website consists of just one sentence. The all-in-one installation method also isn't explained in the official documentation.
A brief side note while I was searching on the web: I believe calling 'emacs file_name' should open a GUI version, while 'emacs -nw file_name' is the console, so I remain using the terminal. But on my Mac, using emacs has the same effect as using emacs -nw. In other words, I can't get a GUI or separate window to show up. Can anyone confirm that this Super User question has the 'correct' answer? (I don't really have a problem with this, as I hate having another pop-up window, but it would be nice to know for completeness.)
The Emacs that comes with Mac OS X /usr/bin/emacs does not have a graphical interface, just the terminal one, so calling emacs is the same as emacs -nw.
Your upgraded Emacs by default starts with the graphical interface, so you need to specify -nw to force it to use the terminal.
There is no "usual" way to upgrade OS X's default Emacs (i.e. Apple does not provide an upgraded Emacs); what you've done is fine. Or you could install a binary from http://emacsformacosx.com/ or use a package manager like homebrew.

Resources