I have a function which renders a plot - how can I pass the plots label information (e.g., plot title, axis titles, etc.) through a function as I'm trying to do below?
library(dplyr)
library(ggplot2)
plot_func <- function(sample_size, lab_list) {
mtcars %>%
sample_n(sample_size) %>%
ggplot(aes(x = mpg, y = hp)) +
geom_point() +
labs(lab_list)
}
plot_func(sample_size = 5, lab_list = list(title = "Plot Title", x = "MPG", y = "HP"))
