gpt4 book ai didi

python - ggplot2 不存在于 python 的 rpy2 中?

转载 作者:太空宇宙 更新时间:2023-11-04 07:46:02 25 4
gpt4 key购买 nike

我在 Python3.2 中使用 rpy2 v2.1.9,我不明白为什么我不能使用库 ggplot2

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

这是我得到的错误信息

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'

最佳答案

查看第一条错误信息的尾部:

there is no package called 'ggplot2'

您需要先安装ggplot2 包。启动 R 本身,然后说

 install.packages("ggplot2")

关于python - ggplot2 不存在于 python 的 rpy2 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7529862/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com