卡方独立性检验chiq.test 发表于 2018-07-31 1234567891011121314151617181920212223242526272829303132# method 1> x=c(454,1833,2120)> y=c(52,216,240)> df=as.table(rbind(x,y))# df=as.table(rbind(c(454,1833,2120),c(52,216,240)))> dfA B CA 454 1833 2120B 52 216 240> chisq.test(df)Pearson's Chi-squared testdata: dfX-squared = 0.1661, df = 2, p-value = 0.9203# method 2> df2=matrix(c(454,1833,2120,52,216,240),nr=3)> df2[,1] [,2][1,] 454 52[2,] 1833 216[3,] 2120 240> chisq.test(df2)Pearson's Chi-squared testdata: df2X-squared = 0.1661, df = 2, p-value = 0.9203