我是 rpy2 新手,在使用 importr 导入 R 包“xts”和“quantmod”时遇到问题
Code is:
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”
版本:
- 蟒蛇版本2.7.3
- R 版本 2.15.2
- rpy2 版本“2.3.0beta1”
任何帮助将不胜感激
Rpy2's importr()
正在尝试转换任何“.”将 R 对象名称更改为“_”以便与 Python 一起使用。
但是,每当有两个 R 对象名称带有“.”时,或“_”(这两个字符对于 R 中的名称均有效) rpy2 报告错误。这里 R 包“xts”定义了两个对象.subset_xts
and .subset.xts
。解决方法是手动指定如何转换名称:
from rpy2.robjects.packages import import
xts = importr("xts", robject_translations = {".subset.xts": "_subset_xts2",
"to.period": "to_period2"})
rpy2 文档中提供了更多有关导入 R 包.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)