[R] RPy and the evil underscore

Alberto Vieira Ferreira Monteiro albmont at centroin.com.br
Sun Feb 25 22:22:14 CET 2007


I seems like I will join two threads :-)

Ok, RPy was installed (in Fedora Core 4, yum -y install rpy), and it 
is running. However, I have a doubt, and the (meagre) documentation
doesn't seem to address it.

In python, when I do this:

>>> import rpy
>>> rpy.r.setwd("/mypath")
>>> rpy.r.source("myfile.r")

Everything happens as expected. But now, there's
a problem if I try to use a function in myfile:

>>> x = my_function(1)
>>> x = r.my_function(1)
>>> x = rpy.my_function(1)
>>> x = rpy.r.my_function(1)

None of them work: the problem is that the _ is mistreated.
If the function has "." instead of "_", it works:

>>> x = rpy.r.my_function(1)

This is weird: I must write the R soutine with a ".", but then
rpy translates it to "_"!

Alberto Monteiro



More information about the R-help mailing list