Reputation: 829
Whenever loading rpy2 in a Jupyter notebook, R code executed with a %%R
cell magic gets printed in the command prompt instead of the notebook cell. Plots show up properly in the notebook though.
I also noticed that the %R
inline magic works properly, with code printed in the cell as expected.
R_USER = C:\Users\myusername
R_HOME = C:\Program Files\R\R-3.3.1
C:\Program Files\R\R-3.3.1\bin\i386
Upvotes: 9
Views: 1251
Reputation: 8242
You can use the RWinOut Jupyter extension. The following installation instructions are taken from the GitHub page:
You can run the following curl
command from a Jupyter notebook cell to download the file to your working directory. You can also download it manually and put it there yourself.
!curl -O "https://raw.githubusercontent.com/vitorcurtis/RWinOut/master/RWinOut.py"
Once it's in your working directory, you can replace %load_ext rpy2.ipython
at the top of your script with %load_ext RWinOut
. Then you should be able to see the output of cells containing the %%R
magic as normal.
This isn't a complete solution, but it's a workaround that might achieve the same effect. I'm not sure if this breaks some functionality, but it seems to work fine for me.
Tested with:
One other option is to use the Windows Subsystem for Linux and launch your Jupyter notebook from there. This might not be desirable if you have to reinstall a lot of R and Python packages into a different environment, but will make it so the output will print correctly without requiring this hacky workaround.
Upvotes: 2