From @ntoine@f@bri @ending from gm@il@com  Tue Aug 21 16:31:13 2018
From: @ntoine@f@bri @ending from gm@il@com (Ant F)
Date: Tue, 21 Aug 2018 16:31:13 +0200
Subject: [Rd] bug report: inaccurate error message for stats::chisq.test
Message-ID: <CAEKh8ugry7UaJ2a3AmjCbkz8iB4cqE7++r523esTuKVvPfRP2w@mail.gmail.com>

Hi,

`stats::chisq.test` checks that x and y each have at least 2 levels AFTER
filtering on complete cases.

It makes sense but the error message is misleading : ?'x' and 'y' must have
at least 2 levels?

Here?s how to reproduce the issue :

    x <- structure(c(1L, 1L, 1L, 2L, 1L, 2L), .Label = c("0001", "0003"),
class = "factor")

    y <- structure(c(1L, 2L, 2L, NA, 2L, NA), .Label = c("0001", "0002"),
class = "factor")

    chisq.test(x,y)

    # Error in chisq.test(...) : 'x' and 'y' must have at least 2 levels

In this case they do have 2 levels.

Best regards,

Antoine

>

	[[alternative HTML version deleted]]



[Rd] bug report: inaccurate error message for stats::chisq.test
Ant F