I want to calculate p-value in python using R.I am using this package rpy2.I am generating count_a and count_b on the fly,and calculate p-values along with it. When I run my script,python closes unexpectedly,and get this error message:

"Error: 'rho' must be an environment not NULL: detected in C-level eval During startup - Warning message:

Abort trap: 6"

The data is below:

```
count_a count_b
94 107
109 92
90 89
18 13
```

Below is my code:

```
import rpy2.robjects as R
out= open(args.outfile, 'w')
binom=R.r['binom.test'](c(count_a,count_b))
P_val=binom['p.value'][0][0]
out.write(str(count_a) + '\t' + str(count_b) + '\t' + str(P_val)
out.close()
```

Any suggestions,or options to calculate p-value in python on a pair of values?

binom object is calculated:

```
Exact binomial test
```

data: c(94L, 107L) number of successes = 94, number of trials = 201, p-value = 0.3974

alternative hypothesis: true probability of success is not equal to 0.5 95 percent confidence interval: 0.3971286 0.5391627

sample estimates:

probability of success

0.4676617

However while extracting the p-value,I am getting this error:

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/rpy2/robjects/vectors.py", line 233, in **getitem** res = super(Vector, self).**getitem**(i) TypeError: 'str' object cannot be interpreted as an index