"Out of nowhere" Zeroes in Contingency Table

Hi! I use RStudio to conduct Chi Square tests. I use table(var1, var2) to create contingency tables, but they look weird as there are numbers (0s) that i have no idea where they are from.

(it shows distribution of genders (male, female) in two groups (experimental and wait list)

When i conduct ChiSquare Tests with those tables, i get this message (half in german, translates to" ChiSquare Approximation my be incorrect").

Warning message:
In chisq.test(table_gen) : Chi-Quadrat-Approximation kann inkorrekt sein

I think it may be due to those extra numbers. Any thoughts on how to fix this? I am a psychology student and not very familiar with programming.
Any help is much appreciated!!

I was told some info on the variable structure would be helpful.

Looking at the last screenshot it seems that you have the empty string ("") in your variable for gender. So the zeros have the empty string to the left of them (which since it is an empty string we can't see ;)) and the zeros themselves are the counts. You can also see that your values being 0 30 14 0 31 15 basically exactly indicate that the "" category has a count of zero. So remove the first (it seems to be the first) row from your table_gen.

EDIT: As to how this might have sneaked into your contingency table, maybe for some reason in the original data you have "" defined as one of the levels of the gender variable?


Thanks! I used the "droplevels"-argument to get rid of that empty string variable.
There is no error message now when i do the Chi Square test.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.