This package allows the user to call Python from R. It is a natural extension of the rJython package by the same author.
rPython is intended for running Python code from R. R programs and packages can:
Here is a sample session with rPython:
python.call( "len", 1:3 )
a <- 1:4
b <- 5:8
python.exec( "def concat(a,b): return a+b" )
python.call( "concat", a, b)
python.assign( "a", "hola hola" )
python.method.call( "a", "split", " " )
Mainly, users and package developers who want to use functionalities available in Python but not in R.
There are many modules in Python which could easily extend R functionality if there would be a way to call Python code from R.
rpy and rpy2, a redesign and rewrite of rpy, are Python interfaces to R. They allow users to call R from Python.
rPython provides the opposite interface.
Besides, no code from rpy/rpy2 has been used in the development of rPython.
One of the most daunting tasks in building an interface between two languages is provide mechanisms for exchanging different data structures between them. rPython uses json:
This simple mechanism allow R and Python exchange relatively complex data structures with ease.
The package can be installed from CRAN:
install.packages("rPython")
This should on Linux and other UNIX-like platforms, such as Mac, but would fail on Windows. Windows users may want to check rPython-win.
Some users want to use rPython using ad hoc Python installations (e.g., Anaconda) or in virtualenvs. It often fails.
Also, it is possible to install rPython to use it on a system installation different from the default one (e.g., Python 3.2 on a system where the default installation is 2.7). It is possible to do so: read the INSTALLATION file contained within the package.
The project summary page can be found here.
The package has been developed by Carlos J. Gil Bellosta and is based on a previous package, rJython, by the same author together with G. Grothendieck.