mean_table: Estimate Percents and 95 Percent Confidence Intervals in...

Description Usage Arguments Value References Examples

View source: R/mean_table.R

Description

The mean_table function produces overall and grouped tables of means with related statistics. In addition to means, the mean_table missing/non-missing frequencies, the standared error of the mean (sem), the 95 value, and the maximum value. For grouped tibbles, mean_table displays these statistics for each category of the group_by variable.

Usage

1
2
mean_table(.data, x, t_prob = 0.975, output = default, digits = 2,
  ...)

Arguments

.data

A tibble or grouped tibble.

x

The continuous response variable for which the statistics are desired.

t_prob

(1 - alpha / 2). Default value is 0.975, which corresponds to an alpha of 0.05. Used to calculate a critical value from Student's t distribution with n - 1 degrees of freedom.

output

Options for this parameter are "default" and "all".

Default output includes the n, mean, sem, and 95 the mean. Using output = "all" also returns the the number of missing values for x and the critical t-value.

digits

Round mean, lcl, and ucl to digits. Default is 2.

...

Other parameters to be passed on.

Value

A tibble of class "mean_table" or "mean_table_grouped"

References

SAS documentation: http://support.sas.com/documentation/cdl/en/proc/65145/HTML/default/viewer.htm#p0klmrp4k89pz0n1p72t0clpavyx.htm

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
library(tidyverse)
library(bfuncs)

data(mtcars)

# Overall mean table with defaults

mtcars %>%
  mean_table(mpg)

#> # A tibble: 1 x 8
#>   response_var     n  mean      sem   lcl   ucl   min   max
#>          <chr> <int> <dbl>    <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1          mpg    32 20.09 1.065424 17.92 22.26  10.4  33.9

# Grouped means table with defaults

mtcars %>%
  group_by(cyl) %>%
  mean_table(mpg)

#> # A tibble: 3 x 10
#>   response_var group_var group_cat     n  mean       sem   lcl   ucl   min   max
#>          <chr>     <chr>     <dbl> <int> <dbl>     <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1          mpg       cyl         4    11 26.66 1.3597642 23.63 29.69  21.4  33.9
#> 2          mpg       cyl         6     7 19.74 0.5493967 18.40 21.09  17.8  21.4
#> 3          mpg       cyl         8    14 15.10 0.6842016 13.62 16.58  10.4  19.2

brad-cannell/bfuncs documentation built on Oct. 20, 2018, 2:39 a.m.