I am new to R and trying to execute the code in this site but unfortunately, I am experiencing this error "Error: unexpected input in "%load_ext rpy2.ipython"" when entering "%load_ext rpy2.ipython" in the R console and I tried searching google for answers but no luck.
Any help would be appreciated. Thank you in advance.
rpy2.ipython
is an extension for ipython, and Jupyter, when you use the IPython kernel. Not for R. What you linked to is using IPython and calling into R from IPython, not calling in Python from within R. Not sure why they do that in what you linked, from a quick read they should use a R kernel, which would work without saying%%R
each time.So you should be able to reproduce what's there by not loading the rpy2 magic, skipping the
%%R
prefixes.If you want to reproduce exactly you will need to install IPython/jupyter and run the code from the Python console.