[R] chisq.test in batch

João Fadista Joao.Fadista at agrsci.dk
Fri Oct 12 00:11:46 CEST 2007


Dear all,
 
I would like to compute hundreds of chisq.test ´s, and for each test output I would like to extract only the p-values. So my question is: how can I make this without making it manually?
 
 
Example:
 
# Test nº1
 > chisq.test(c(220,240))
 
        Chi-squared test for given probabilities
data:  c(220, 240) 
X-squared = 0.8696, df = 1, p-value = 0.3511
 
# Test nº2
 > chisq.test(c(301,258))
        Chi-squared test for given probabilities
data:  c(301, 258) 
X-squared = 3.3077, df = 1, p-value = 0.06896
 
...
 
# Test nº200
> chisq.test(c(242,281))
        Chi-squared test for given probabilities
data:  c(242, 281) 
X-squared = 2.9082, df = 1, p-value = 0.08813
 
 
Desired output:
Test       1           2             ... 200
p-value   0.3511   0.06896   ... 0.08813
 
 
 
Thanks in advance.
Best regards,
João Fadista
 

 

 



More information about the R-help mailing list