[R-sig-eco] Why use Rpy?

Gregory, Matthew matt.gregory at oregonstate.edu
Wed Jul 2 19:31:59 CEST 2008

Philip Dixon wrote:
> What is the benefit of using Rpy?
> I'm familiar with Python as a high-level compiled language.  
> Python was very popular here (Iowa State, Statistics) a few 
> years ago to vastly speed up S+ simulation studies.  One 
> could recode into Python a lot more quickly than recoding 
> into C++.  Both Python and C++ were much faster than S+; I 
> don't know how Python compares with native R.

I guess since I think I was the one who brought it up, I should probably
explain my rationale.  The really glib answer (for me) is that I know
Python and wasn't willing to learn another programming language for the
small bit that I needed from R (probably not a very popular opinion on
an R listserve ...).  RPy provides that relatively seamless link into R
and given that most of our codebase is in Python, this was the path of
least resistance for me.  There is also the RSPython package which has
similar functionality to RPy.  

I can only speak to the benefits that I've found from Python, which
isn't to say they don't exist in R - I'm just not fully aware of them.
The main strength of Python for me is the vast array of amazing packages
that are written for it.  This includes: 

-  Numpy/Scipy/matplotlib for array handling, scientific computing and
-  bindings for GDAL for abstract spatial translation and projection
-  PIL for image processing
-  numerous other packages that have nothing to do with statistical

I realize that most of this functionality already exists in R, so
probably not worth getting into Python if R fits your needs.  

As for speed, I can't speak to the R vs. Python question, although
colleagues that are R users do complain about memory limitations and
speed when running large spatial models.  Python will be slower than
C/C++, but the things that *need* to be fast can be coded in C/C++ and
be bound to Python using SWIG.

I'm sure that someone on this list probably has much more experience
with both languages than I do and will provide a better answer.  

Matt Gregory
Faculty Research Assistant
Department of Forest Science
Oregon State University

More information about the R-sig-ecology mailing list