Description Usage Arguments Value Examples
compare2numvars
computes either t_var_test or wilcox.test,
depending on parameter gaussian. Descriptive statistics, depending on distribution,
are reported as well.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
data |
name of dataset (tibble/data.frame) to analyze. |
dep_vars |
vector of column names for independent variables. |
indep_var |
name of grouping variable, has to translate to 2 groups. If more levels are encountered, an error is produced. |
gaussian |
logical specifying normal or ordinal values. |
round_p |
level for rounding p-value. |
round_desc |
number of significant digits for rounding of descriptive stats. |
range |
include min/max? |
rangesep |
text between statistics and range or other elements. |
pretext |
for function formatP. |
mark |
for function formatP. |
n |
create columns for n per group? |
add_n |
add n to descriptive statistics? |
A tibble with variable names, descriptive statistics, and p-value, number of rows is number of dep_vars.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # Assuming Normal distribution:
compare2numvars(
data = mtcars, dep_vars = c("wt", "mpg", "qsec"), indep_var = "am",
gaussian = TRUE
)
# Ordinal scale:
compare2numvars(
data = mtcars, dep_vars = c("wt", "mpg", "qsec"), indep_var = "am",
gaussian = FALSE
)
# If dependent variable has more than 2 levels, consider fct_lump:
mtcars %>% mutate(gear=factor(gear) %>% fct_lump_n(n=1)) %>%
compare2numvars(dep_vars="wt",indep_var="gear",gaussian=TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.