Function for simple (grouped) descriptive analyses.

quick_sum(df, var, ..., stats = "all", protect = FALSE)

Arguments

df

dataframe

var

variables to be aggregated

...

grouping variables

stats

Which descriptive statistics should be computed? Can be "all", "base", or "mean". See details.

protect

Apply data protection, can be TRUE or FALSE. See details.

Details

If stats is set to "all" (the default), the following descriptive statistics are computed per category of the grouping variable(s): mean, standard deviation, 10%-quantile, 25%-quantile, median, 75%-quantile, 90%-quantile. If stats is set to "base", the mean, 25%-quantile, median, and 75%-quantile are returned. stats = "mean" computes the mean and the standard deviation. If protect is set to TRUE, the mean and the median is only computed for variables/variable categories with four or more observations. For <4 observations, the function returns NA for the respective variable/category. The other descriptives are only computed if there are at least 6 observations per variable (category).

Examples

quick_sum(df = mtcars, var = cyl, mpg, vs, stats = "all", protect = FALSE)
#> # A tibble: 26 × 10
#>      mpg    vs Anzahl mean_cyl sd_cyl q10_cyl q25_cyl med_cyl q75_cyl q90_cyl
#>    <dbl> <dbl>  <int>    <dbl>  <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>
#>  1  10.4     0      2        8      0       8       8       8       8       8
#>  2  13.3     0      1        8     NA       8       8       8       8       8
#>  3  14.3     0      1        8     NA       8       8       8       8       8
#>  4  14.7     0      1        8     NA       8       8       8       8       8
#>  5  15       0      1        8     NA       8       8       8       8       8
#>  6  15.2     0      2        8      0       8       8       8       8       8
#>  7  15.5     0      1        8     NA       8       8       8       8       8
#>  8  15.8     0      1        8     NA       8       8       8       8       8
#>  9  16.4     0      1        8     NA       8       8       8       8       8
#> 10  17.3     0      1        8     NA       8       8       8       8       8
#> # ℹ 16 more rows