Get a table of descriptive statistics for numeric or factor variables
Source:R/descriptives.R
get_desc_table.RdThis function returns a table of descriptive statistics generated by some tbl_fn function.
Additionally, statistics can be computed separately by groups. Groups can also be compared using
some ana_fn function.
Arguments
- df
data.frame
- vars
Vector of variable names
- tbl_fn
Function that generates table
- group
Name of grouping variable
- ana_fn
Function that computes p-values (or other statistics to compare groups)
- ...
Additional named arguments passed to
ana_fn
Details
For numeric variables, a natural choice is to use tbl_fn=tbl_fn_num(), while for
categorical variables, use tbl_fn=tbl_fn_fac(). Alternatively, custom functions can be specified.
If group is specified, you have the option of requesting p-values (or some other statistic)
comparing groups. For numeric variables, a natural choice is ana_fn=ana_fn_aov(), which
computes p-values using analysis of variance. For factor variables, p-values can be obtained
with Chi-square tests using ana_fn=ana_fn_chisq().