plot_mean_table: Plot multiple outcomes and confidence intervals efficiently

Description Usage Arguments Value Examples

View source: R/mean_tables.R

Description

Plot multiple outcomes and confidence intervals efficiently

Usage

1
2
3
4
5
6
7
8
plot_mean_table(tab, y_mean = est, y_max = upp, y_min = low,
  y_names = outcome, color_var = NULL, shape_var = NULL,
  dodge = 0.5, outcome_order = c("in_order", "reverse_order",
  "by_value", "user_supplied"), title = NA, subtitle = NA,
  dates = NA, caption = NA, reverse_legend = T,
  x_axis_lab = element_blank(), y_axis_lab = element_blank(),
  x_scale = "default", color_scheme = "Dark2", x_min = 0,
  x_max = NA_real_)

Arguments

tab

A data.frame with columns containing an estimate of the mean, and upper bound for the CI, and a lower bound for the CI (for point estimate, upper CI bound, and lower CI bound)

y_mean

Name of column where estimate of mean is stored

y_max

Name of column where upper bound of CI is stored

y_min

Name of column where lower bound of CI is stored

y_names

Name of column where names of outcomes are stored

color_var

Name of grouping variable to differtiate by color (if any)

shape_var

Name of grouping variable to differtiate by shape (if any)

dodge

Numeric indicating the distance between estimates

outcome_order

Character determining how outcomes should be ordered. Default preserves the order in which values first appear in the data.frame

title

A string supplying the title. Often good to standarized half of it at the top of the section or document and then customize it with paste()

subtitle

A string supplying the subtitle which is typically the question stem of survey questions that are being presented as outcomes

dates

A string supplying the dates of the survey to go in the caption. Supplying dates trigger the following format for the captaion: the words "National Sample, N = XXX, Time Period: dates" where the XXX is caluated by the function calculates

caption

A string

x_axis_lab

A string w/ desired name of x-axis.

y_axis_lab

A string w/ desired name of y-axis.

x_scale

A string defaulting to "default" in which case the x-axis will go from 0 to x_max.

color_scheme

String supplying the color scheme.

x_max

Numberic indicating highest deisred value for x-axis

Value

A ggplot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
data(ca_school_tbl_svy)

named_outcome_vec <- c(`Fully qualified teachers` ="qual.teach.prop",
                       `New students`= "new.stu.prop",
                       `English language learners` = "eng.lang.learn.prop")

tab <- surv_mean_table(ca_school_tbl_svy, named_outcome_vec,
                       c("poverty", "year.round.sch"),
                       prop.to.pct = T, wrap = F)

plot_mean_table(tab, color_var = poverty, shape_var = year.round.sch,
               x_max = 110)

rm(tab)

mattysimonson/exploratorium documentation built on Dec. 21, 2021, 3:49 p.m.