Calculates N, mean, standard deviation, and a two-sided confidence interval for the mean of a numeric vector.

calc_stats(x, conf_level = 0.95, decimal_places = 2)

Arguments

x

(numeric)
vector to summarize.

conf_level

(probability)
The confidence level for the interval (default is 0.95).

decimal_places

(integer)
Number of decimal places for numeric values in the table.

Value

A list with statistics: n, mean, mean_ci_lwr, mean_ci_upr, median, sd.

Examples

x <- c(10, 20, 40, NA, 30)
calc_stats(x, conf_level = 0.95, decimal_places = 2)
#> $n
#> [1] 4
#> 
#> $mean
#> [1] 25
#> 
#> $mean_ci
#> [1] "4.46 45.54"
#> 
#> $mean_ci_lwr
#> [1] 4.46
#> 
#> $mean_ci_upr
#> [1] 45.54
#> 
#> $median
#> [1] 25
#> 
#> $sd
#> [1] 12.90994
#>