ggchisqtest: Plot for Pearson's Chi-squared Test for Count Data

Description Usage Arguments Examples

View source: R/ggchisqtest.R

Description

Visualise chi-squared contingency table tests and goodness-of-fit tests.

Usage

1
2
ggchisqtest(t, colaccept="lightsteelblue1", colreject="gray84", 
colstat="navyblue", alpha=0.05)

Arguments

t

a list result of chisq.test of "htest" class

colaccept

color the acceptance area of the test

colreject

color for the rejection area of the test

colstat

color for the test statistic vline

alpha

default set to 0.05, choose confidence level for the plot as it is not stated in chisqtest

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## Chi-squared test for given probabilities

x <- c(A = 20, B = 15, C = 25)
chisq_test <- chisq.test(x)
chisq_test
ggchisqtest(chisq_test)


x <- c(10, 86, 45, 38, 10)
p <- c(0.10, 0.40, 0.20, 0.20, 0.10)
chisq_test2 <- chisq.test(x, p = p)
chisq_test2
ggchisqtest(chisq_test2)



## Pearson's Chi-squared test

library(MASS)
sex_smoke <- table(survey$Sex, survey$Smoke)
chisq_test3 <- chisq.test(sex_smoke)
chisq_test3
ggchisqtest(chisq_test3)

gginference documentation built on Nov. 10, 2020, 5:10 p.m.