Ok, so how do I work out the indices? The following is an edited dump of
the contents of the list returned by 'shapiro.test'. The structure is
complicated and the documentation describes the list in terms of the named
components. It is not apparent how to use indices to access the "W" or
the "p-value"
Shapiro-Wilk normality test
data: c(0.02680463, 0.01925946, 0.01254716, 0.0154345, 0.004379203,
0.01027525, 0.01059046, 0.003602925,
<removed lots of data>
0.006231989, 0.009011005, 0.00636412, 0.005571512, 0.01034128,
0.01379226, 0.008606928)
W = 0.9619, p-value = 1.751e-15
Regular users of rpy2 must have worked something out that allows them
convenient access to the named components?
By the way, I do appreciate the patience you have shown. Thanks much for
the help!
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
"B.A.D.C.M.D Santos" <bac...@cam.ac.uk>
Sent by: "B.A.D.C.M.D Santos" <bac...@hermes.cam.ac.uk>
02/09/2010 08:04 AM
To
john.schroe...@inl.gov
cc
rpy-list@lists.sourceforge.net
Subject
[Rpy] Access to R lists
res = super(RVector, self).__getitem__(i)
TypeError: 'str' object cannot be interpreted as an index
This answer is pretty much self explanatory. If you have a list or an
array
you can access is items by using indices. For example list=['a','b'] To
access the first element ('a') you do list[0], so it is the same for R.
It is probably a better idea to just do reply to your previous examples
instead of opening a new thread.
Best,
Bruno
2010/2/9 John A Schroeder <john.schroe...@inl.gov>
Hello again,
I am still working on variations of the "faithful" example. The last thing
I need to resolve is how to access R lists (and later maybe data frames)
from rpy2 (2.0.8). It seems the following code should allow access to
items
in the list returned by the 'shapiro.test' object/function.
print
print "Shapiro-Wilks normality test of unavailability data"
shapiro_test = robjects.r('shapiro.test')
sw = shapiro_test(uaData)
print "W = %.4f" % sw['statistic']['W']
print "p-value = %.5f" % sw['p.value']
The following is the result:
Shapiro-Wilks normality test of unavailability data
Traceback (most recent call last):
File "D:\Users\roe\Eclipse\workspace\SimPyProjects\src\MachSim01.py",
line 228, in <module>
if __name__ == '__main__': main()
File "D:\Users\roe\Eclipse\workspace\SimPyProjects\src\MachSim01.py",
line 216, in main
print "W = %.4f" % sw['statistic']['W']
File "C:\Python26\lib\site-packages\rpy2\robjects\__init__.py", line
267,
in __getitem__
res = super(RVector, self).__getitem__(i)
TypeError: 'str' object cannot be interpreted as an index
If the above does not work, how do I access items in the returned list?
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
------------------------------------------------------------------------------
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
------------------------------------------------------------------------------
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