Hello. I'm not a regular subscriber in this mailing list, but I think that this announce may interest somebody. Please, forgive me if this is the wrong place. Based on the code of RSPython, but modifying it a little, I wrote an interface for using R from Python. The main reason for writing it was to make it robust, in order to avoid segmentation faults. Also, it is (IMMO) a very transparent interface between Python and R. It is downloadable from http://www.cmat.edu.uy/~walterm/rpy I attach a fragment of the README. Regards: Walter -- -------------- Walter Moreira <> Centro de Matematica <> Universidad de la Republica email: walterm at cmat.edu.uy <> Home Page: http://www.cmat.edu.uy/~walterm RPy 0.1 - Python interface to the R Programming Language 1. WHAT IS RPy? RPy is a very simple, yet robust, interface to the R Programming Language (http://www.r-project.org). It can manage all kinds of R objects and can execute arbitrary R functions (including the graphic functions). All the errors from the R language are converted to Python exceptions. Any module that later were installed on the R system, can easily be used from within Python, without introducing any changes. Currently it works only under Linux/Unix. This code is inspired in RSPython from the Omegahat project (http://www.omegahat.org/RSPython). [...snip...] 3. USING RPy For details see the file USING. As a quick example, try the following session: >>> from rpy import * >>> >>> l = [r.dchisq(x, 4) for x in r.seq(0, 10, by=0.1)] >>> r.par(ask=1, ann=0) >>> r.plot(l, type='lines') and voila!, the graph of the density of a chi squared distribution with 4 degrees of freedom should appear. Refer to the file USING for more info on the interface, and to the R Programming Language manuals, which can be found on http://www.r-project.org In general, every line of the R manuals can be translated almost directly to Python. See the conversion directives in section 5 of file USING. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Walter Moreira wrote:> > Based on the code of RSPython, but modifying it a little, I wrote an interface > for using R from Python. The main reason for writing it was to make it robust, > in order to avoid segmentation faults. Also, it is (IMMO) a very transparent > interface between Python and R. > > It is downloadable from > > http://www.cmat.edu.uy/~walterm/rpyWow, as a keen but frustrated RSPython user, this looks great. Did someone manage to download a copy of Walter's work which they can temporarily mirror somewhere? Alas, the URL given above is unreachable for now. Tim C -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Fri, Mar 08, 2002 at 07:24:27AM +1100, Tim Churches wrote:> I can see your server now but Duncan Temple Lang was kind enough to send > me a copy of RPy in the meantime. He commented that he thought that R > objects in RPy aren't being protected from garbage collection but that > was easy to fix.Yes, Duncan is probably right, I don't fully understand the R api wrt garbage collection. Could you or Duncan send me some indications about where it is needed the protection from gc? Thank you.> >>> from rpy import * > > gives > > Traceback (most recent call last): > File "rpy_test.py", line 1, in ? > from rpy import * > File "/usr/local/lib/python2.1/site-packages/rpy.py", line 23, in ? > from _rpy import * # If this fails, you need to compile the C > extension > ImportError: libR.so: cannot open shared object file: No such file or > directory > > Hmmm. libR.so exists in /usr/lib/R/bin, which is in my path. > > If I issue > > ld _rpymodule.so > > then ld complains it can't find libR.so > > ld -rpath /usr/lib/R/bin _rpymodule.so > > fixes this error. But how to I tell _rpymodule.so where to look for > libR.soPerhaps you need to run ldconfig after the installation to rearrange the libraries. Then you can try ldd _rpymodule.so to see if all libraries were found. I think they should. Regards: Walter -- -------------- Walter Moreira <> Centro de Matematica <> Universidad de la Republica email: walterm at cmat.edu.uy <> Home Page: http://www.cmat.edu.uy/~walterm +-------------------------------------------------------- /OD\_ | hundred-and-one symptoms of being an internet addict: O o . |_o_o_) | 167. You have more than 100 websites in your | Bookmark. --+-- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._