plot_trends_across_group.Rd
This function generates a faceted line plot for a given dataset, allowing the user to specify the x-axis, y-axis, grouping variable, and facet variable. Additionally, users can include standard errors and customize labels.
plot_trends_across_group(
data,
x_var,
y_var,
grouping_var,
facet_var,
se = NULL,
include_legend = TRUE,
title = "Dependent Variable across Years by Group and Industry",
x_label = "Year",
y_label = "Dependent Variable",
theme = causalverse::ama_theme(),
...
)
A data frame containing the data to be plotted.
A character string specifying the x-axis variable.
A character string specifying the y-axis variable.
A character string specifying the grouping variable.
A character string specifying the facet variable.
A character string specifying the standard error variable, or NULL (default) if not provided.
Logical. If TRUE, includes the legend, otherwise it does not.
Character string specifying the main plot title.
Character string specifying the x-axis label.
Character string specifying the y-axis label.
A ggplot2 theme. Defaults to ama_theme
.
Additional arguments passed to labs
.
A ggplot object.
if (FALSE) {
# Create a small sample dataset
sample_data <- data.frame(
year = rep(2001:2005, each = 2),
dependent_variable = rnorm(10, mean = 50, sd = 10),
group = rep(c("treated", "control"), times = 5),
industry = rep(c("Tech", "Healthcare"), each = 5)
)
# Use the function
plot_trends_across_group(data = sample_data,
x_var = "year",
y_var = "dependent_variable",
grouping_var = "group",
facet_var = "industry",
title = "Sample Title")
}