Search code examples
rggplot2jupyter-notebookcluster-computingrpy2

ggplot function not found in jupyter notebook with rpy2


I am working on a computer cluster and testing out how to use a Jupyter notebook on it. I encountered this problem while trying to use ggplot2. I've tried installing the package in the notebook, with R in the command line, and with conda install, and r-ggplot2 (version 2.2.1) shows up in conda packages. Any ideas?

The error I got on the notebook is here


Solution

  • Judged by your screenshot, you are running a python-based notebook. It looks as if you are trying to use ggplot as part of the python package rpy2.

    Based on this source, ggplot is present in rpy2.robjects.lib.ggplot2, so you might want to try something like

    from rpy2.robjects.lib.ggplot2 import ggplot
    
    ...
    ggplot(data=df)