2014-02-24 63 views
0

我在R中安裝了RServe,在Python中安裝了pyRserve。兩者都很好。我遵循文檔https://pythonhosted.org/pyRserve/manual.html,事情運作良好。然而,當我嘗試運行到sapply相關的例子中,我得到以下錯誤:R環境中的pyRserve 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試過了,但它仍然得到同樣的錯誤。你知道這是否是規範的改變,或者如果有另一種方法來做到這一點?

謝謝!

回答

1

這是一個遲到的回覆,但也許它仍然可以幫助別人。

在pyRserve中確實有一個提供R函數作爲函數調用參數的錯誤。這已在V 0.8.1中得到修復,現在應按預期工作。