Different P values for chi square test in Python and R
<p>I am trying to do chi square test on two categories of biological data. I have a data frame like this:</p>

<pre><code>         Brain, Cerebelum, Heart, Kidney,  liver,  testis
expected 3        66       1        44       34       88
observed 6        57       4        45       35       69

structure(list(Brain = c(3L, 6L), Cerebelum = c(66L, 57L), heart = c(1L, 
4L), kidney = 44:45, liver = 34:35, testis = c(88L, 69L)), .Names = c("Brain", 
"Cerebelum", "heart", "kidney", "liver", "testis"), class = "data.frame", row.names = c("rand", 
"cns"))
</code></pre>

<p>I did the test using Python:</p>

<pre><code>from scipy.stats import chisquare
chisquare(obs,f_exp=exp)
</code></pre>

<p>which gives result as:</p>

<pre><code>Power_divergenceResult(statistic=17.381684491978611, pvalue=0.0038300192430189722)
</code></pre>

<p>I tried to replicate the results using R, so I made the csv file, imported to R as dataframe and run the code as:</p>

<pre><code>d&lt;-read.csv(file)
chisq.test(d)

Pearson's Chi-squared test

data:  d
X-squared = 4.9083, df = 5, p-value = 0.4272
</code></pre>

<p>why the chi squared value and P value is different in python and R?, As I calculated by hand using the simple (O-E)^2/E formula, the chi square value is equal to 17.38 as calculated by python but I can not figure out how R calculate the value of 4.90.</p>