This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> mtcars$gear | |
[1] 4 4 4 3 3 3 3 4 4 4 4 3 3 3 3 3 3 4 4 4 3 3 3 3 3 4 5 5 5 5 5 4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
table(mtcars$gear, mtcars$cyl) | |
4 6 8 | |
3 1 2 12 | |
4 8 4 0 | |
5 2 1 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prop.table(table(mtcars$gear, mtcars$cyl)) | |
4 6 8 | |
3 0.03125 0.06250 0.37500 | |
4 0.25000 0.12500 0.00000 | |
5 0.06250 0.03125 0.06250 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> chisq.test(mtcars$gear, mtcars$cyl) | |
Pearson's Chi-squared test | |
data: mtcars$gear and mtcars$cyl | |
X-squared = 18.036, df = 4, p-value = 0.001214 | |
Warning message: | |
In chisq.test(mtcars$gear, mtcars$cyl) : | |
Chi-squared approximation may be incorrect |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> fisher.test(mtcars$gear, mtcars$cyl) | |
Fisher's Exact Test for Count Data | |
data: mtcars$gear and mtcars$cyl | |
p-value = 8.26e-05 | |
alternative hypothesis: two.sided |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> chisq.test(mtcars$gear, mtcars$cyl, simulate.p.value = TRUE) | |
Pearson's Chi-squared test with simulated p-value (based on 2000 | |
replicates) | |
data: mtcars$gear and mtcars$cyl | |
X-squared = 18.036, df = NA, p-value = 0.0004998 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> prop.table(table(mtcars$gear, mtcars$cyl))*100 | |
4 6 8 | |
3 3.125 6.250 37.500 | |
4 25.000 12.500 0.000 | |
5 6.250 3.125 6.250 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> library(DescTools) | |
> GTest(mtcars$gear, mtcars$cyl) | |
Log likelihood ratio (G-test) test of independence without | |
correction | |
data: mtcars$gear and mtcars$cyl | |
G = 23.26, X-squared df = 4, p-value = 0.0001123 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> addmargins(table(mtcars$gear, mtcars$cyl)) | |
4 6 8 Sum | |
3 1 2 12 15 | |
4 8 4 0 12 | |
5 2 1 2 5 | |
Sum 11 7 14 32 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> colSums(table(mtcars$gear, mtcars$cyl)) | |
4 6 8 | |
11 7 14 |