我在 R 中安装了 RServe,在 Python 中安装了 pyRserve。两者都工作得很好。我遵循了文档https://pythonhosted.org/pyRserve/manual.html,一切运行良好。但是,当我尝试运行与 sapply 相关的示例时,出现以下错误:
>>> conn = pyRserve.connect()
>>> conn.r.sapply(numpy.array([-1,2,3]), conn.r.abs)
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2827, in run_code
exec code_obj in self.user_global_ns, self.user_ns
File "<ipython-input-68-8dcf5b40049c>", line 1, in <module>
conn.r.sapply(numpy.array([1, 2, 3]), conn.ref.abs)
File "/usr/lib/python2.7/site-packages/pyRserve-0.7.3-py2.7.egg/pyRserve/rconn.py", line 301, in __call__
return self._rconn.callFunc(self._name, *args, **kw)
File "/usr/lib/python2.7/site-packages/pyRserve-0.7.3-py2.7.egg/pyRserve/rconn.py", line 47, in decoCheckIfClosed
return func(self, *args, **kw)
File "/usr/lib/python2.7/site-packages/pyRserve-0.7.3-py2.7.egg/pyRserve/rconn.py", line 190, in callFunc
argName = arg.name
File "/usr/lib/python2.7/site-packages/pyRserve-0.7.3-py2.7.egg/pyRserve/rconn.py", line 333, in __getattr__
'defined in Rserve' % concatName)
NameError: no such variable or function "abs.name" defined in Rserve
我尝试使用 conn.ref.abs,但仍然出现相同的错误。您知道这是否是规范的更改,还是有其他方法可以做到这一点?
谢谢!