-->

rpy2 importr与XTS和quantmod失败(rpy2 importr failing w

2019-07-04 08:08发布

我是新来rpy2和使用importr导入R程序包“XTS”和“quantmod”我有麻烦

代码如下:

from rpy2.robjects.packages import importr
xts = importr('xts')
quantmod = importr('quantmod')

错误是:

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)

我不使用importr许多其他包搞定这个问题,例如,“统计”,“图形”,“动物园”,“GGPLOT2”

版本:

  • Python版本2.7.3
  • [R版本2.15.2
  • rpy2版本 '2.3.0beta1'

任何帮助将不胜感激

Answer 1:

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"})

更多的是关于rpy2文档中提供进口的R程序包 。



文章来源: rpy2 importr failing with xts and quantmod