Package: pyRserve
What pyRserve doespyRserve is a library for connecting Python toR(an excellent statistic package). RunningRservein R attaches the R-interpreter to a network socket, waiting for pyRserve to connect to it.
Through such a connection, variables can be get and set in R from Python,
and also R-functions can be called remotely.In contrast torpy or rpy2the R process does not have to
run on the same machine, it can run on a remote machine and all variable  access and
function calls will be delegated there through the network.Furthermore - and this makes everything feel very pythonic - all data structures will
automatically be converted from native R to native Python and numpy types and back.Supported platformsThis package has been mainly developed under Linux, and hence should run on all standard unix
platforms, as well as on MacOS. pyRserve has also been successfully used on Windows machines.
Unittests have been used on the Linux and MacOS side, however they might just work fine for Windows.It has been tested to work with Python 2.7.x, 3.6 to 3.9.The latest development has been tested with some previous and current versions of R and Rserve.LicensepyRserve has been written by Ralph Heinkel(ralph-heinkel.com)and is
released underMIT license.Quick installationFrom your unix/macOS,windows command line run:pip install pyRserveFor a fully functional setup also R and Rserve have to be installed. See sectioninstallationin the pyRserve
documentation for instructions.Quick usageOpen afirst shelland start up the R server, by calling the moduleRservethat provides
the actual network connectivity for R:$ R CMD RserveR (Rserve) will now listen on port 6311 (on localhost). Of course Rserve can be configured to
listen on an exposed port and hence will be accessible from remote hosts as well.Open asecond shell, start Python, import pyRserve, and initialize the connection to Rserve:$ python
>>> import pyRserve
>>> conn = pyRserve.connect()The default connection will be done onlocalhost:6311. Other hosts can be reached by
callingpyRserve.connect(host=...,port=...)as well.Theconnobject provides a namespace calledconn.rthat directly maps all variables
and other global symbols (like functions etc) and hence makes them accessible from Python.Now create a vector in R, access the vector from Python (will be converted into a numpy array), and
call thesum()-function in R:>>> conn.r("vec <- c(1, 2, 4)")
>>> conn.r.vec                 # access vector 'vec' as an attribute of 'conn.r'
array([1., 2., 4.])
>>> conn.r.sum(conn.r.vec)     # 'sum' in running in the R-interpreter, returning the result to Python
7.0The other way around also works:>>> conn.r.somenumber = 444         # set a variable called 'somenumber' in the R interpreter...
>>> conn.r("somenumber * 2")        # ... and double the number
888.0Source code repositorypyRserve is now hosted on GitHub athttps://github.com/ralhei/pyRserve.DocumentationDocumentation can be found athttps://pyrserve.readthedocs.io.SupportFor discussion of pyRserve and getting help please use the Google newsgroup
available athttp://groups.google.com/group/pyrserve.Issues with the code (like bugs, etc.) should be reported on GitHub athttps://github.com/ralhei/pyRserve/issues.Missing featuresAuthentication is implemented in Rserve but not yet in pyRserveTLS encryption is not implemented yet in pyRserve. However using ssh tunnels
can solve security issues in the meantime (see documentation).