title: Statistics Tests (Kolmogorov and T-test) with Python and Rpy2
body: <p>I've runned some algorithms and wanted to make some statistics analysis with the results. I have two vectors with the averages of the error rate.</p>
  
  <p>With R, using the line below I would get everything.</p>
  
  <pre><code>t.test(methodresults1,methodresults2,var.equal=FALSE,paired=FALSE,alternative="less")
  </code></pre>
  
  <p>Since I'm using Python, I wanted to use Rpy2 project.</p>
  
  <p>I tried that:</p>
  
  <pre><code>import rpy2.robjects as R
  
  # methodresults1 and methodresults2 are numpy arrays.
  
  # kolmogorov test
  normality_res = R.r['ks.test'](R.FloatVector(methodresults1.tolist()),'pnorm',mean=R.FloatVector(methodresults1.mean().tolist()),sd=R.FloatVector(methodresults1.std().tolist())))
  
  # t-test
  res = R.r['t.test'](R.FloatVector(methodresults1.tolist()),R.FloatVector(methodresults2.tolist()),alternative='two.sided',var.equal=FALSE,paired=FALSE)
  
  res.rx('p.value')[0][0]
  res.rx('statistic')[0][0]
  res.rx('parameter')[0][0]
  </code></pre>
  
  <p>I wasn't able to perform both tests.</p>
  
  <p>I found also that the problem with the t-test is with the var.equal statement and it gives me an <em>*</em> SyntaxError: keyword can't be an expression (, line 1).</p>
  
  <p>Extra question: Is there a better way to work with numpy and Rpy2?</p>