I am trying to get the two most basic RPy examples to work.   I am on a 
Windows XP platform (also trying Window 7, and OpenSUSE 11.2, none work, 
all seem to have different problems!) I have both rpy and rpy2 installed.  
I have R version 2.10.1, and Python 2.6.  Also the most recent versions of 
NumPy and SciPy.  Consider EXAMPLE 1 below.  This example works, however, 
EXAMPLE 2 below does not.  EXAMPLE 3 shows what happens when I try the 
"faithful" example. 

I am hoping to use RPy to process simulation output from SimPy.   Getting 
the "faithful" example to work would be a very good start!  Can anyone 
point me in the right direction?


John A. Schroeder
Idaho National Laboratory
Battelle Energy Alliance, LLC
P.O. Box 1625
Idaho Falls, ID  83415-3850

Ph:   208-526-8755
FAX:  208-526-2930

EXAMPLE 1. -- This works!

from rpy2.robjects import *

def main():
    degrees = 4
    grid = r.seq(0, 10, length=100)
    values = [r.dchisq(x, degrees) for x in grid]
    r.par(ann=0)
    r.plot(grid, values, type='l')

if __name__ == '__main__': main()


EXAMPLE 2. -- This does not work!

from rpy import *

def main():
    degrees = 4
    grid = r.seq(0, 10, length=100)
    values = [r.dchisq(x, degrees) for x in grid]
    r.par(ann=0)
    r.plot(grid, values, type='l')

if __name__ == '__main__': main()


This example produces the following result:

Traceback (most recent call last):
  File "D:\Users\roe\Eclipse\workspace\SimPyProjects\src\RPy01.py", line 
7, in <module>
    from rpy import *
  File "C:\Python26\lib\site-packages\rpy.py", line 58, in <module>
    RVERSION = rpy_tools.get_R_VERSION(RHOME)
  File "C:\Python26\lib\site-packages\rpy_tools.py", line 103, in 
get_R_VERSION
    raise RuntimeError("Couldn't obtain version number from output\n"
RuntimeError: Couldn't obtain version number from output
of `R --version'.


When I check the R version manually at the command prompt I get:

D:\Users\roe>R --version
R version 2.10.1 (2009-12-14)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License version 2.
For more information about these matters see
http://www.gnu.org/licenses/.


EXAMPLE 3.  This does not work

The "faithful" example,  the only change is the following:

#from rpy import *
from rpy2.robjects import *

This is the result:

Summary of Old Faithful eruption duration data
Traceback (most recent call last):
  File "D:\Users\roe\Eclipse\workspace\SimPyProjects\src\RPy02.py", line 
26, in <module>
    for k in edsummary.keys():
AttributeError: 'RArray' object has no attribute 'keys'

When I use the rpy import, I am back to the result from EXAMPLE 2:
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to