make_boxplot <- function(df, plot_column){
if (!is.numeric(df[[plot_column]])){
stop('The column to plot must be numcerial.')
}
p <- ggplot(df, aes(y = .data[[plot_column]])) +
geom_boxplot(fill = "#03579A") +
labs(title = paste("Boxplot of", plot_column)) +
theme_bw()
return(p)
}
Exercise 4, Functions- Solutions
Here we show the content inside solution4_functions.R
. Remember, the file containing your outsourced functions needs to be an R script (.R), not a quarto document!