使用rpy2 importr将R包Rssa导入到python中

时间:2015-02-18 20:30:18

标签: python r rpy2 ssa

当我在Python命令中执行时

rssa = importr('Rssa')

我得到了eroor

Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    rssa = importr('Rssa')
  File "C:\Python34\lib\site-packages\rpy2\robjects\packages.py", line 412, in importr
    version = version)
  File "C:\Python34\lib\site-packages\rpy2\robjects\packages.py", line 178, in __init__
    self.__fill_rpy2r__(on_conflict = on_conflict)
  File "C:\Python34\lib\site-packages\rpy2\robjects\packages.py", line 280, in __fill_rpy2r__
    super(SignatureTranslatedPackage, self).__fill_rpy2r__(on_conflict = on_conflict)
  File "C:\Python34\lib\site-packages\rpy2\robjects\packages.py", line 233, in __fill_rpy2r__
    rpyobj = conversion.ri2ro(riobj)
  File "C:\Python34\lib\functools.py", line 707, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
  File "C:\Python34\lib\site-packages\rpy2\robjects\__init__.py", line 101, in _
    return SignatureTranslatedFunction(obj)
  File "C:\Python34\lib\site-packages\rpy2\robjects\functions.py", line 150, in __init__
    raise ValueError("Error: '%s' already in the translation table. This means that the signature of the R function contains the parameters '%s' and/or '%s' <sigh> in multiple copies." %(r_param, r_param, prm_translate[py_param]))
ValueError: Error: '...' already in the translation table. This means that the signature of the R function contains the parameters '...' and/or '...' <sigh> in multiple copies.

导入其他包时没有问题,例如

stats = importr('stats')
tseries = importr('tseries')
forecast = importr('forecast')

我一直在寻找这样的问题,但我找不到任何接近的东西。请提出一些关于这个问题的决定。

1 个答案:

答案 0 :(得分:0)

这是由于Rssa试图控制'分解'功能(从'stats'包中导出)时的错误引起的。特别是,在形式列表中'''被添加两次,这就是rpy2抱怨的内容。

这将在随后的Rssa版本中修复。

唯一的解决方法是在R / common.R中注释掉以下行:

formals(decompose.default) <- c(formals(decompose.default), alist(... = ))

从源代码重新安装Rssa。这在Windows上可能并不重要,尽管R windows构建器可以在这里提供帮助。