wakeup
wakeup

Reputation: 67

Rserve: pyServe not able to call basic R functions

I'm calling Rserve from python and it runs for basic operations, but not if I call basic functions as min

import pyRserve

conn = pyRserve.connect()

cars = [1, 2, 3]
conn.r.x = cars
print(conn.eval('x'))
print(conn.eval('min(x)'))

The result is:

[1, 2, 3]
Traceback (most recent call last):
  File "test3.py", line 9, in <module>
    print(conn.eval('min(x)'))
  File "C:\Users\acastro\.windows-build-tools\python27\lib\site-packages\pyRserve\rconn.py", line 78, in decoCheckIfClosed
    return func(self, *args, **kw)
  File "C:\Users\acastro\.windows-build-tools\python27\lib\site-packages\pyRserve\rconn.py", line 191, in eval
    raise REvalError(errorMsg)
pyRserve.rexceptions.REvalError: Error in min(x) : invalid 'type' (list) of argument

Do you know where is the problem? Thanks

Upvotes: 0

Views: 79

Answers (1)

Trung Anh Phạm
Trung Anh Phạm

Reputation: 87

You should try min(unlist(x)).

If the list is simple, you may just try as.data.frame(x).

For some more complicate list, StackOverFlow has many other answers.

Upvotes: 1

Related Questions