| ts_plot | R Documentation |
Generates time-series plots, optionally faceted by specified groups. The
resulting object can be customized using ggplot2 functions and themes.
ts_plot(
formula = NULL,
y = NULL,
group = NULL,
time_var = NULL,
intervention_var = NULL,
df,
tsi = NULL,
weights = NULL,
ncol = 2
)
formula |
An object of class |
y |
Name of the variable in |
group |
Name of the variable in |
time_var |
Name of the variable in |
intervention_var |
Name of the cohort-level variable in |
df |
A data frame containing the variables in the model. |
tsi |
An object of class |
weights |
An optional vector of weights to be passed to |
ncol |
Number of columns in the faceted plot |
Returns an object of class "ggplot"
# Use a formula to specify the setup of the time-series plot. Here we set
# hospitalized as the outcome, faceted by county, with yr on the X axis.
ts_plot(hospitalized ~ county + yr,
df = hosp,
intervention_var = "intervention_yr")
# We can specify the same plot without using a formula.
ts_plot(y = "hospitalized",
group = "county",
time_var = "yr",
df = hosp,
intervention_var = "intervention_yr")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.