Chunk where you install and/or load all necessary packages
Vitamin C example’s contingency table and chi-square test
ski.reg<-matrix(c(31, 17, 109, 122), ncol=2, dimnames=list(Treatment=c("Placebo", "VitaminC"), Cold=c("Cold", "NoCold")))
ski.reg %>%
kbl(caption = "French Skiers Regular") %>%
kable_classic(full_width = F, html_font = "Cambria")
French Skiers Regular
|
Cold
|
NoCold
|
Placebo
|
31
|
109
|
VitaminC
|
17
|
122
|
result.reg<-chisq.test(ski.reg, correct = FALSE) # without CC
result.reg
##
## Pearson's Chi-squared test
##
## data: ski.reg
## X-squared = 4.8114, df = 1, p-value = 0.02827
Deflated Version
ski.deflate<-matrix(c(3, 2, 11, 12), ncol=2, dimnames=list(Treatment=c("Placebo", "VitaminC"), Cold=c("Cold", "NoCold")))
ski.deflate %>%
kbl(caption = "French Skiers Deflated") %>%
kable_classic(full_width = F, html_font = "Cambria")
French Skiers Deflated
|
Cold
|
NoCold
|
Placebo
|
3
|
11
|
VitaminC
|
2
|
12
|
result.def<-chisq.test(ski.deflate, correct = FALSE) # without CC
result.def
##
## Pearson's Chi-squared test
##
## data: ski.deflate
## X-squared = 0.24348, df = 1, p-value = 0.6217
Inflated Vesrion
ski.inflate<-matrix(c(310, 170, 1090, 1220), ncol=2, dimnames=list(Treatment=c("Placebo", "VitaminC"), Cold=c("Cold", "NoCold")))
ski.inflate %>%
kbl(caption = "French Skiers Inflated") %>%
kable_classic(full_width = F, html_font = "Cambria")
French Skiers Inflated
|
Cold
|
NoCold
|
Placebo
|
310
|
1090
|
VitaminC
|
170
|
1220
|
### Pearson's Chi-squared test with Yates' continuity correction
result.inf<-chisq.test(ski.inflate, correct = FALSE)
result.inf
##
## Pearson's Chi-squared test
##
## data: ski.inflate
## X-squared = 48.114, df = 1, p-value = 4.021e-12