my.chi.sq: chi square test to get expected value and p value

Description Usage Arguments Examples

View source: R/demo_Graphic.R

Description

chi square test to get expected value and p value

Usage

1

Arguments

...

variables

Examples

1
2
3
4
5
6
7
8
set.seed(2018)
group <-round(abs(rnorm(500)*10),0) %% 2
cont_1 <-round(abs(rnorm(500)*10),0)
cat_multi_1 <-round(abs(rnorm(500)*10),0) %% 3
data_check <-data.frame(group, cont_1, cat_multi_1)
data_check$group <- factor(data_check$group, levels = c(0,1), labels = c("Control","Treatment"))
data_check$cat_multi_1 <- factor(data_check$cat_multi_1)
my.chi.sq(table(data_check$cat_multi_1, data_check$group))

Example output

[[1]]
   
    Control Treatment
  0  82.944    79.056
  1  88.576    84.424
  2  84.480    80.520

[[2]]
[1] 0.1866314

demoGraphic documentation built on May 1, 2019, 7:58 p.m.