Вопрос

I installed RServe in R and pyRserve in Python. Both are working great. I followed the documentation https://pythonhosted.org/pyRserve/manual.html, and things are working well. However, when I tried to run the example related to sapply, I get the following error:

>>> 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

I tried with conn.ref.abs, but it still gets the same error. Do you know if this is a change of specification, or if there is another way to do this?

Thanks!

Это было полезно?

Решение

This a late reply, but maybe it can still help others.

There was indeed a bug in pyRserve with providing R functions as arguments for function calls. This has been fixed in V 0.8.1 and should now work as expected.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top