ggplot2 not present in rpy2 for python?

亡梦爱人 提交于 2019-12-08 07:37:46

问题


I am working with rpy2 v2.1.9 in Python3.2, I don't understand why I can't use the library ggplot2

import rpy2
from rpy2.robjects import r
r.library("ggplot2")

Here is the error message I got

Error in function (package, help, pos = 2, lib.loc = NULL, character.only = FALSE,  : 
  there is no package called 'ggplot2'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.2/dist-packages/rpy2/robjects/functions.py", line 82, in __call__
     return super(SignatureTranslatedFunction, self).__call__(*args, **kwargs)
   File "/usr/local/lib/python3.2/dist-packages/rpy2/robjects/functions.py", line 34, in __call__
     res = super(Function, self).__call__(*new_args, **new_kwargs)
 rpy2.rinterface.RRuntimeError: Error in function (package, help, pos = 2, lib.loc = NULL, character.only = FALSE,  : 
   there is no package called 'ggplot2'

回答1:


See the tail of the first error message:

there is no package called 'ggplot2'

You need to install the ggplot2 package first. Fire up R itself, and say

 install.packages("ggplot2")


来源:https://stackoverflow.com/questions/7529862/ggplot2-not-present-in-rpy2-for-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!