newbie python question: doing more than one thing in a for loop
i'm using the rpy module to interface the R statistics language.
the first print line (with the "-" before it) at the bottom
of the script gives ~500 of the following:
{'null.value': {'difference in means': 0.0}, 'data.name': 'c(0.007,
0.007, 0.135) and c(0.072, 0.003, 0.033)', 'method': 'Welch Two
Sample t-test', 'p.value': 0.79164656667870525, 'statistic': {'t':
0.29009514644766238}, 'estimate': {'mean of y': 0.035999999999999997,
'mean of x': 0.049666666666666671}, 'conf.int': [-0.14127029902675267,
0.16860363236008602], 'parameter': {'df': 2.8365235114711265},
'alternative': 'two.sided'}
i want to add the lines with the "+" to extract the p.value from the
dictionary data type above, while in the loop.
#!/usr/bin/python
# import MySQL module
import MySQLdb
from rpy import *
# connect
db=MySQLdb.connect(host="localhost", user="xxx", passwd="xxx",
db="2d-gels")
# create a cursor
cursor=db.cursor()
# execute SQL statement
cursor.execute("SELECT * FROM `022704`")
# get the resultset as a tuple
result=cursor.fetchall()
# iterate through resultset
for record in result:
- print r.t_test(record[0:4],record[4:8])
+ fulldata = r.t_test(record[0:4],record[4:8])
+ print fulldata['p.value']
|