invalid 'x' error in chi-square test

I am getting invalid 'x' error in chi-square test. Kindly refer below code and guide.

attach (br)
table(br$East, br$West, br$North, br$South)
chisq.test(table(br$East, br$West, br$North, br$South))

Error in chisq.test(table(br$East, br$West, br$North, br$South)) :
invalid 'x'

The documentation for chisq.test() says that x, the first parameter, has to be a vector or matrix, that is, an object with one or two dimensions. You are passing it a table with four dimensions. If you try

chisq.test(table(br$East, br$West))

you should not get that error, though the result may not be meaningful for your application

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