Skip to content
Prev 170819 / 398506 Next

Python and R

2009/2/17 Esmail Bonakdarian <esmail.js at gmail.com>:
I tend to use R in its native form for data analysis and modelling,
and python for all my other programming needs (gui stuff with PyQt4,
web stuff, text processing etc etc).
When I need to use the two together, it's easiest with 'rpy'. This
lets you call R functions from python, so you can do:

 from rpy import r
 r.hist(z)

to get a histogram of the values in a python list 'z'. There are some
complications converting structured data types between the two but
they can be overcome, and apparently are handled better with the next
generation Rpy2 (which I've not got into yet). Google for rpy for
info.
Not sure what you mean here. Do you mean is:

 R> sum(x)

faster than

Python> sum(x)

and how much worse is:

Python> from rpy import r
Python> r.sum(x)

?

 Knuth's remark on premature optimization applies, as ever....

Barry