我已经在这里引用了这篇文章。 将 Python 列表转换为 R 数值向量
我遇到了同样的错误,但提供的解决方案对我不起作用,所以我发布了它。我在Linux中使用python 2.7和rpy2对应的最新版本
我尝试使用 rpy2 从 python 调用 R 函数,我的前几行如下。
import rpy2.robjects as robjects
from rpy2.robjects.packages import importr
import rpy2.robjects.numpy2ri
rpy2.robjects.numpy2ri.activate()
r=robjects.r
astsa=importr('astsa')
astsa.acf2(L, 3) # L:a numeric list returned by my omitted code,I checked
错误如下:
Traceback (most recent call last):
File "/home/jin/Desktop/main.py", line 63, in <module>
astsa.acf2(traffic[0], 3)
File "/usr/lib/python2.7/dist-packages/rpy2/robjects/functions.py", line 86, in __call__
return super(SignatureTranslatedFunction, self).__call__(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/rpy2/robjects/functions.py", line 35, in __call__
res = super(Function, self).__call__(*new_args, **new_kwargs)
RRuntimeError: Error in stats::acf(series, max.lag, plot = FALSE) : 'x' must be numeric