I have a dataframe, and want to perform for each row (3x2 contingency table) a chi squared test .
- row 1 102 4998 105 3264 105 3636
- row 2 210 4890 22 3347 20 3721
- row 3 ...
So for the first row a chi squared test should be performed for the following contingency table;
- group A 102 4998
- group B 105 3264
- group C 105 3636
I use the following code, but this does not calculate the correct p-value (all p-values are equal to zero while this is not the case when I calculate the chi-square test myself):
table <- read.delim("dataframe.txt")
apply(table, 1, function(x) chisq.test(matrix(x,nrow=3)))
Could anyone help me with this?
Thank you in advance
Wannes