[R] chisq.test error: x and y must have at least 2 levels

Christoph Bier christoph.bier at web.de
Fri Nov 7 16:48:43 CET 2003


Peter Dalgaard wrote:

> Well, the error message might be slightly beside the point, but the
> issue would seem to be that there are no "ja"'s inside either vector.
> I.e. it first reduces each factor to those levels that are actually
> present, then checks whether there are at least two levels.

Thanks for this explanation.

> You can't do a chisquare test on a table that looks like this
> 
>       nein   ja
> nein    42    0
>   ja     0    0
> 

Hm, and now? There is data like this and I need to do a chisquare 
test. Spencer's answer seems to be the solution.
    Is my data that uncommon, that chisq.test hasn't a built-in 
function to avoid this error?

Best regards,

Christoph




More information about the R-help mailing list