I am using the following function for calculating means and also percentages among the dependent variable and comparing them.
summary_factorlist(data, dependent, explanatory, add_dependent_label=T, p=T, p_cat = "fisher", p_cont_para = "aov", fit_id = T)
I was wondering how I can the following code (to make table1) in order to apply the fisher exact test when the number of obs among the level of a factor and dependent variable is less than 5,otherwise apply the chi-square?
library(finalfit)
library(dplyr)
# Load example dataset, modified version of survival::colon
data(colon_s)
Table 1 - Patient demographics
explanatory = c("age", "age.factor", "sex.factor", "obstruct.factor")
dependent = "perfor.factor"
colon_s %>%
summary_factorlist(dependent, explanatory, add_dependent_label=T, p=T, p_cat = "fisher", p_cont_para = "aov", fit_id = T)
colon_s %>%
summary_factorlist(dependent, explanatory, add_dependent_label=T, p=T, p_cat = "chisq", p_cont_para = "aov", fit_id = T)