This function gives you a mean with 95 percent CIs
mean_ci(df, var, wt, ci = 0.95)
df | Name of the Dataset |
---|---|
var | Variable to find the mean of |
wt | Weight to be applied |
ci | Confidence Interval, expressed as a decimal. i.e. .84. Defaults to .95 |
cces <- read_csv("https://raw.githubusercontent.com/ryanburge/blocks/master/cces.csv")#> Warning: Missing column names filled in: 'X1' [1]#>#> #>cces %>% mean_ci(gender)#> # A tibble: 1 x 7 #> mean sd n level se lower upper #> <dbl> <dbl> <int> <dbl> <dbl> <dbl> <dbl> #> 1 1.54 0.499 500 0.05 0.0223 1.49 1.58# Weighted Means cces %>% mean_ci(gender, wt = commonweight_vv)#> # A tibble: 1 x 6 #> mean sd n se lower upper #> <dbl> <dbl> <int> <dbl> <dbl> <dbl> #> 1 1.50 0.499 500 0.0223 1.46 1.54# Change the Confidence Interval cces %>% mean_ci(gender, ci = .84)#> # A tibble: 1 x 7 #> mean sd n level se lower upper #> <dbl> <dbl> <int> <dbl> <dbl> <dbl> <dbl> #> 1 1.54 0.499 500 0.16 0.0223 1.50 1.57