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