开发者

How to have recognized all the libraries Rpy2 R

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 Tracebac开发者_StackOverflow中文版k (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


In order to get the importr command to work, you probably need to upgrade your version of rpy2 -- try checking your version:

print rpy2.__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:

In [1]: import rpy2.robjects as robjects

In [2]: R = robjects.r  

In [3]: from rpy2.robjects.packages import importr

In [4]: importr("utils")
Out[4]: <rpy2.robjects.packages.SignatureTranslatedPackage object at 0x1e96310>

I'm not sure what you're trying to do, as those libraries should work without any extra importing, as Gavin has mentioned.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜