rgoogle-colaboratoryrpy2

Conversion 'py2rpy' not defined for objects of type '<class 'str'>'


I am trying to run R in a google collab notebook (which worked fine before, however as I now tried to access it and run it it keeps giving me an error).

I have ran the following:



    %load_ext rpy2.ipython

    %%R 
    install.packages('rworldmap')
    install.packages('classInt')
    install.packages('reshape2')
    install.packages('dplyr')
    install.packages('ggpubr')

NotImplementedError: Conversion 'py2rpy' not defined for objects of type '<class 'str'>'

I have tried re-opening the notebook or creating a new one but I keep having the same issue.


Solution

  • This is a problem with newer versions. You must downgrade rpy: run in a cell:

    !pip install rpy2==3.5.1

    restart and try again

    From this post.