rpy2 importr使用xts和quantmod失败

PHC*_*PHC 3 conflict r rpy2 xts quantmod

我是rpy2的新手,并且在使用importr导入R软件包'xts'和'quantmod'时遇到问题

代码是:

from rpy2.robjects.packages import importr
xts = importr('xts')
quantmod = importr('quantmod')
Run Code Online (Sandbox Code Playgroud)

错误是:

LibraryError: Conflict when converting R symbol in the package "xts" to a Python symbol (.subset.xts -> _subset_xts while there is already _subset_xts)

LibraryError: Conflict when converting R symbol in the package "quantmod" to a Python symbol (skeleton.TA -> skeleton_TA while there is already skeleton_TA)
Run Code Online (Sandbox Code Playgroud)

对于许多其他软件包,使用importr我没有遇到这个问题,例如'stats','graphics','zoo','ggplot2'

版本:

  • python版本2.7.3
  • R版本2.15.2
  • rpy2版本'2.3.0beta1'

任何帮助将不胜感激

lga*_*ier 5

Rpy2 importr()试图转换任何"." 在R对象名称为"_"用于Python.

但是,只要有两个R对象名称带有".".或"_"(两个字符对R中的名称有效)rpy2报告错误.这里的R包"xts"定义了两个对象.subset_xts.subset.xts.解决方法是手动指定如何转换名称:

from rpy2.robjects.packages import import
xts = importr("xts", robject_translations = {".subset.xts": "_subset_xts2", 
                                             "to.period": "to_period2"})
Run Code Online (Sandbox Code Playgroud)

有关导入R软件包的rpy2文档中提供了更多信息.