I have R 3.3.0 on Mac Yosemite 10.10.5 and Python 2.7.11 and rpy2 2.7.0.
ggplot2 is installed in R Console and my R script - additional_plots.R - works perfectly in R Console.
However, I need to run the script additional_plots.R from Python (because all of my other code is in Python). When I run:
import rpy2.robjects as robjects
My error message is:
/Users/chriseal/anaconda/lib/python2.7/site-packages/rpy2/robjects/robject.py:6: UserWarning: Warning: rpy2.rinterface.initr()
/Users/chriseal/anaconda/lib/python2.7/site-packages/rpy2/robjects/robject.py:6: UserWarning: namespace ‘ggplot2’ is not available and has been replaced by .GlobalEnv when processing object ‘p1’
/Users/chriseal/anaconda/lib/python2.7/site-packages/rpy2/robjects/robject.py:6: UserWarning: namespace ‘scales’ is not available and has been replaced by .GlobalEnv when processing object ‘p3’
rpy2.rinterface.initr()
I have also tried:
import subprocess
retcode = subprocess.call(['RScript','additional_plots.R'])
And received an error that references ggplot2, saying that it isn't installed.
I have tried installing 'ggplot2' within rpy2, and it installs with no errors, but when I try to run additional_plots.R, I get an error saying 'ggplot2' isn't available.
I don't understand why ggplot2 is installed in R Console, but can't be accessed via Python. How do I access ggplot2 - or furthermore, ensure that I can access all libraries available in R Console - from Python?
Thanks!! Chris
Aucun commentaire:
Enregistrer un commentaire