Say we want to test the independence between cyl_six and drv_front using mpg data file.
> table(cyl_six, drv_front) drv_front cyl_six 0 1 0 23 62 1 105 44 > chisq.test(table(cyl_six, drv_front)) Pearson's Chi-squared test with Yates' continuity correction data: table(cyl_six, drv_front) X-squared = 39.4295, df = 1, p-value = 3.401e-10
Notice by default, the chisq.test will provide the Chi-squared test with Yates’ continuity correction, which equal to the ‘Continuity Adj. Chi-Square‘ result on SAS result. In order to conduct without correction, adding correct = argument in the function.
> chisq.test(table(cyl_six, drv_front), correct = FALSE) Pearson's Chi-squared test data: table(cyl_six, drv_front) X-squared = 41.1627, df = 1, p-value = 1.401e-10