View source: R/QualitativeStatistics.R
QualitativeStatistics | R Documentation |
Make contingency table of counts per group and, if the table is 2x2, perform Fisher's exact test. If not, perform a chi square test. Can perform tests counts of each value within a variable as well if multilevel is set to TRUE.
QualitativeStatistics( data, id_var, group_var, tst_vars, multilevel = FALSE, test_use = "proportion", yates = TRUE, flip_dir = FALSE, correct_var = NULL )
data |
the input data frame |
id_var |
the id variable to group obsetrvations by |
group_var |
the grouping variable, passed as a string |
tst_vars |
variables to perform the test on; can be passed as a vector of strings |
multilevel |
if TRUE, then function will perform analyses on all values with a variable between the group |
test_use |
specify either 'proportion' or 'logistic_regress' Note: logistic regression is only done if multilevel == TRUE |
yates |
whether to use yate's continuity correction or not. chisq.test defaults to TRUE, while gtsummary's add_p defaults to FALSE |
flip_dir |
short for 'flip directionality.' set to true if want to predict the variable *using* the outcome instead |
correct_var |
if performing a logistic regression, can specify an additional variable to correct for |
out <- QualitativeStatistics(data, group_var = "CMD", tst_vars = c("Gender", "Etiology", "Race"), multilevel = TRUE) # since multilevel is TRUE, will have results for male and female, all etiologies, and all races. print(out$Etiology$SAH) print(out$Etiology$ICH) print(out$Gender$M) print(out$Gender$F)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.