RPY2: importr does not work .Renviron

Here, what should and should happen using rpy2.robjects.packages.importrbasic R packets (for example, stats):

>>> from rpy2.robjects.packages import importr
>>> importr('stats')
<rpy2.robjects.packages.SignatureTranslatedPackage object at 0x7f3810>

but with an external package (e.g. ggplot2) this is the result:

>>> importr('ggplot2')
Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE,  :
  there is no package called 'ggplot2'
Error in .Primitive("as.environment")("package:ggplot2") : 
  no item called "package:ggplot2" on the search list
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/7.0/lib/python2.7/site-packages/rpy2/robjects/packages.py", line 100, in importr
    env = _as_env(rinterface.StrSexpVector(['package:'+name, ]))
rpy2.rinterface.RRuntimeError: Error in .Primitive("as.environment")("package:ggplot2") : 
  no item called "package:ggplot2" on the search list

The complication is that in my home directory I have a file .Renvironthat determines the location of my user library (where, for example, ggplot2libs), and I have no problems with any of the R-commands library()or require()with Rand Rscript. The path looks something like this:

R_LIBS_USER="/path/to/my/packages"

So my question is, why is my user library path excluded from the "search list" Rpy2? Or rather, how do I direct Rpy2for a search on the go R_LIBS_USER?

, Rpy2, .

R: 2.13.0
Platform: x86_64-apple-darwin9.8.0/x86_64 (Mac, 10.6, 64-bit)

Rpy2: 2.1.8, 2.2.1 (dev)

R, ggplot2 python, .

+3
1

rpy2 "vanilla", R_LIBS .

>>> import rpy2.rinterface 
>>> rpy2.rinterface.get_initoptions()
('rpy2', '--quiet', '--vanilla', '--no-save')
>>> 

'rinterface.set_initoptions()' .

:

import rpy2.rinterface as ri
ri.set_initoptions(('rpy2', '--verbose', '--no-save'))
ri.initr()

# from now on, just import the rest of rpy2 modules without thinking of the above.
+2

All Articles