Cran via Native Python Library Wrapping

pip install cran==0.1.14



Crantastic & Pythonic!

  • Intuitive interface, which fills cran. namespace with package functions upon .library().
  • Automatically generate CRAN-like PDFs from the docstrings!

Note. Currently, main place where all packages are stored is:

sudo apt-get update
sudo apt-get upgrade gcc
sudo apt-get install python2.7-dev

pip install cran

>>> import cran
>>> df = cran.pd.DataFrame({'x': [0.025, 0.050, 0.100, 0.150, 0.200, 0.300], 
                            'y': [0.596, 0.725, 1.867, 2.408, 3.777, 2.728]})
>>> cran.max(df)
>>> cran.install_packages('lm')
>>> cran.library('lm')
>>> cran.lm(...)

Idea: CRAN Simulation for Python

The CRAN ( is the place, which statisticians traditionally publish code for new statistical methods. It is special in its research-centric culture -- code is based on new theories published in statistical journals, and it is documented in publication-like PDFs. Here ( ) is a model example, of how to write a clean R package for linear regression.

Being that I now primarily write code in Python, it looks like I am missing this type of culture. Importing culture is not like "import this", however.

To interface with systems, Python developers are very adept at creating interfaces. In this case, however, we would need and interface with people -- make it easy for statisticians to write and document statistical methods in Python, the CRAN-way.

In Python, we already have much of R functionality, which is mainly covered in NumPy, Pandas, StatsModels, SciKit Learn. However, it is largely unfamiliar to statisticians.

One obvious way is to write a kind of CRAN wrapper, which is composed of packages with the same names as in CRAN, but written using Python native data types instead of using rpy2.

Start from

Model example of how to create Package in R:

More info

So, I had started the placeholder for this attempt. I'll see, where it gets. I started a package cran on PyPI to try to implement it. If you want to use the namespace, and find this one inactive, please, let me know (


  • cran.install(, src), cran.library(). The .install would copy from internet location to local .cran/ folder, and cran.library() would add specific locatins to PYTHONPATH?