简体   繁体   English

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

[英]R packages Rssa is not imported to python with rpy2 importr

When I executed in Python command 当我在Python命令中执行时

rssa = importr('Rssa')

I got eroor 我得到了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.

Other packages are imported without problem, as example 例如,其他包导入没有问题

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

I was looking for such problem, but I could not find nothing close. 我一直在寻找这样的问题,但我找不到任何接近的东西。 Please, suggest some decision of this problem. 请提出一些关于这个问题的决定。

This was caused by bug in Rssa when it tries to take control over 'decompose' function (which is exported from 'stats' package). 这是由于Rssa在试图控制'分解'功能(从'stats'包中导出)时的错误引起的。 In particular, in the list of formals '...' is added twice and this is what rpy2 is complaining about. 特别是,在正式列表'...'中添加两次,这就是rpy2抱怨的内容。

This will be fixed in the subsequent Rssa releases. 这将在随后的Rssa版本中修复。

The only workaround is to comment out in R/common.R the following line: 唯一的解决方法是在R / common.R中注释掉以下行:

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

And reinstall Rssa from source. 并从源代码重新安装Rssa。 This might be non-trivial on Windows, though R windows builder can help here. 这在Windows上可能并不重要,尽管R windows构建器可以在这里提供帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM