qstats: Calculate basic statistics on a quantitative variable

Description Usage Arguments Details Examples

Description

Does a tidy calculation of basic stats. "Tidy" means that qstats() takes a data table as input and produces a data table as output. The output will have one column for each of the statistics requested as well as columns for any grouping variables.

Usage

1
qstats(formula, data, ..., .level = 0.95, .wide = FALSE)

Arguments

formula

indicating which variables are to be used. See details.

data

the data table containing the variables

...

the names of the statistics desired. Default: the favorite statistics from fav_stats() in the mosaic package.

.level

the confidence or coverage level (default: 0.95)

.wide

format the output in a nice way for human reading. The default is to output a tidy data table with one row for each of the groups defined by the categorical variables on the right side of the formula.

Details

Use a one-sided formula if there is only one quantitative variable involved or a two-sided formula with the quantitative variable on the left and categorical variables on the right. Note that qstats() uses only the formula to define splitting into groups and ignores any grouping imposed by dplyr::group_by(). It is unlike dplyr::summarise() in that respect. QUESTION: Should this be configured to work both with group_by() and the formula, using all the variables mentioned.

Available statistics:

Examples

1
2
3
mtcars %>% qstats( ~ hp, mean, median, sd.conf)
mtcars %>% qstats(hp ~ cyl, mean, median, sd.conf)
mtcars %>% qstats(hp ~ cyl)

dtkaplan/statPREPpackage documentation built on May 15, 2019, 5:22 p.m.