Skip to main content

Mapping R API to Python

Project description

Interoperate R with Python

Main codecov pypi Conda version

Installation

# 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 python 2.7 and 3.5+.

Getting started

from rchitect import *
a = reval("1:5")     # evaluate an R expression in the global environment
b = rcopy(a)         # convert any RObject returned by `reval` to its python type
c = robject(b)       # convert any python object to its R type
d = rcall("sum", c)  # call an R function. Python objects are converted to RObjects implicitly.

FAQ

How to switch to a different R or specify the version of R.

There are a few options.

  • One could expose the path to the R binary in the PATH variable
  • The environment variable R_BINARY could also be used to specify the path to R.
  • The environment variable R_HOME could also be used to specify R home directory. Note that it is should be set as the result of R.home(), not the directory where R is located. For example, in Unix
$ env R_HOME=/usr/local/lib/R radian

Cannot find shared library

Please also make sure that R was installed with the R shared library libR.so or libR.dylib or libR.dll. On Linux, the flag --enable-R-shlib may be needed to install R from the source.

Wiki

reticulate conversions

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rchitect-0.3.36.tar.gz (32.7 kB view hashes)

Uploaded source

Built Distributions

rchitect-0.3.36-cp310-cp310-win_amd64.whl (65.3 kB view hashes)

Uploaded cp310

rchitect-0.3.36-cp310-cp310-win32.whl (63.0 kB view hashes)

Uploaded cp310

rchitect-0.3.36-cp39-cp39-win_amd64.whl (65.3 kB view hashes)

Uploaded cp39

rchitect-0.3.36-cp39-cp39-win32.whl (63.0 kB view hashes)

Uploaded cp39

rchitect-0.3.36-cp38-cp38-win_amd64.whl (65.3 kB view hashes)

Uploaded cp38

rchitect-0.3.36-cp38-cp38-win32.whl (63.0 kB view hashes)

Uploaded cp38

rchitect-0.3.36-cp37-cp37m-win_amd64.whl (65.3 kB view hashes)

Uploaded cp37

rchitect-0.3.36-cp37-cp37m-win32.whl (63.0 kB view hashes)

Uploaded cp37

rchitect-0.3.36-cp36-cp36m-win_amd64.whl (65.3 kB view hashes)

Uploaded cp36

rchitect-0.3.36-cp36-cp36m-win32.whl (63.0 kB view hashes)

Uploaded cp36

rchitect-0.3.36-cp35-cp35m-win_amd64.whl (64.2 kB view hashes)

Uploaded cp35

rchitect-0.3.36-cp35-cp35m-win32.whl (61.8 kB view hashes)

Uploaded cp35

rchitect-0.3.36-cp27-cp27m-win_amd64.whl (62.8 kB view hashes)

Uploaded cp27

rchitect-0.3.36-cp27-cp27m-win32.whl (61.2 kB view hashes)

Uploaded cp27

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page