Friday 6 March 2009

Dynamic Languages: R with Python

Previously I've discussed using Python as a primary general-purpose language calling S as a statistics and graphics engine. The capabilities for doing this have been improving over the years. First there was RSPython by Duncan Temple Lang, then rpy by Greg Warnes, and most recently rpy2 by Laurent Gautier.

Here's an example using rpy2 for principal components analysis:


import rpy2.robjects as robjects

r = robjects.r

m = r.matrix(r.rnorm(100), ncol=5)
pca = r.princomp(m)
r.plot(pca, main="Eigen values")
r.biplot(pca, main="biplot")




It's pretty readable for an S programmer, so this looks promising.

Unfortunately it doesn't currently seem to work with IronPython via IronClad. Perhaps someday...

1 comment:

  1. First there was RSPython by Duncan Temple Lang, then rpy by Greg Warnes, and most recently rpy2 by Laurent Gautier. feng shui singapore

    ReplyDelete