[R] Getting all possible contingency tables

Christofer Bogaso bogaso.christofer at gmail.com
Sat Dec 1 13:25:15 CET 2012


Hello all,

Let say I have 2-way contingency table:

Tab <- matrix(c(8, 10, 12, 6), nr = 2)

and the Chi-squared test could not reject the independence:

 > chisq.test(Tab)

         Pearson's Chi-squared test with Yates' continuity correction

data:  Tab
X-squared = 1.0125, df = 1, p-value = 0.3143


However I want to get all possible contingency tables under this 
independence scenario (one of them would obviously be the given table 
as, we could not reject the independence), and for each such table I 
want to calculate the Ch-sq statistic.

Can somebody help me how to generate all such tables?

Thanks and regards,



More information about the R-help mailing list