# install released version
pip install -U rchitect
# or the development version
pip install -U git+https://github.com/randy3k/rchitect
Why reinvent the wheel?
You may be curious why I reinvented the wheel when there is rpy2?
The main reason is to drive radian.
rpy2 was not suitable because it is missing some key features for running
the R REPL. Speaking of compatibility, rchitect has been thoroughly tested on
multiple platforms such as Windows, macOS and Linux and we also provide binary
wheels for user convenience.
fromrchitectimport*a=reval("1:5")# evaluate an R expression in the global environmentb=rcopy(a)# convert any RObject returned by `reval` to its python typec=robject(b)# convert any python object to its R typed=rcall("sum",c)# call an R function. Python objects are converted to RObjects implicitly.
If rchitect fails to open the R shared library, user should first
try to expose the path to R to the PATH vaiable.
In Linux/macOS, you could also export the environment variable R_HOME. For example,
Sometimes, you may also need to futher specify LD_LIBRARY_PATH if R fails to find some shared libraries,