如何识别 Rpy2 R 的所有库
如何识别所有库 Rpy2 R.
Rpy2 无法识别库、实用程序和工具。
import rpy2.robjects as robjects
R = robjects.r
>>> R['library']("utils")
RVector - Python:0x7f65fc85cfc8 / R:0x19bb980
>>> R['library']("tools")
RVector - Python:0x7f65fc85f5a8 / R:0x2419140
(>> from rpy2.robjects.packages import importr 回溯(最近一次调用最后一次): 文件“”,第 1 行,位于 导入错误:没有名为包的模块 )
因为我可以更新 Rpy2 以毫无问题地加载所有库或 R 可以完成的操作。
PS:我在ubuntu上使用R 2.10和python 2.6
How to have recognized all the libraries Rpy2 R.
Rpy2 not recognizing the libraries, utils, and tools.
import rpy2.robjects as robjects
R = robjects.r
>>> R['library']("utils")
RVector - Python:0x7f65fc85cfc8 / R:0x19bb980
>>> R['library']("tools")
RVector - Python:0x7f65fc85f5a8 / R:0x2419140
(>>> from rpy2.robjects.packages import importr
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named packages
)
as I can update Rpy2 to load all the libraries without problems or R that can be done.
PS: I use R 2.10 and python 2.6 on ubuntu
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为了使 importr 命令正常工作,您可能需要升级 rpy2 的版本 - 尝试检查您的版本:
我相信您需要 2.1.0 或更高版本。以下内容适用于 2.1.7,但不适用于 2.0.3:
我不确定您要做什么,因为正如 Gavin 提到的那样,这些库应该无需任何额外的导入即可工作。
In order to get the importr command to work, you probably need to upgrade your version of rpy2 -- try checking your version:
I believe you need version 2.1.0 or greater. The following works for me under 2.1.7 but not on 2.0.3:
I'm not sure what you're trying to do, as those libraries should work without any extra importing, as Gavin has mentioned.
除非我弄错了——我不使用 Rpy2——这些包(顺便说一下,它们不是库)会在 R 启动时自动加载;您无需执行任何其他操作即可使用它们。这些包中的所有用户可见的函数都在 R 启动期间可用。
另外,您无法更新这些软件包 - 它们是 R。只有当您更新 R 本身时,您才能获得更新。在这一点上,它们与推荐包(如 nlme、mgcv、MASS 等)不同,这些包也在 CRAN 上,并且在 R 版本更新之间更新得更频繁。
Unless I am mistaken - I don't use Rpy2 - these packages (they are not libraries by the way) are loaded automatically when R is started; you do not need to do anything else to make use of them. All the user-visible functions in these packages are made available during R start up.
Also, you can't update these packages - they are R. You only get updates when you update R itself. In this they differ from the Recommended packages (like nlme, mgcv, MASS etc) which are also on CRAN and which are updated more frequently in between R version updates.