I am working on creating a custom ggplot2 theme for my work. The style guidelines say that all figure titles should be capitalized. My question is whether there is a way to accomplish this from within the custom theme function. Looking at the options in the element_text function seems that I can't simply do it through that.
I know I could create a custom labs function that would capitalize the title but I would prefer that it is done within the custom theme function so that users don't have to remember to call both the custom theme and the custom labs function.
Here is my desired output:
library(ggplot2)
ggplot(mtcars, aes(mpg, hp)) +
geom_point() +
labs(
title = "My plot title"
)

my_labs <- function(title, ...){
labs(title = stringr::str_to_upper(title), ...)
}
# desried output
ggplot(mtcars, aes(mpg, hp)) +
geom_point() +
my_labs(
title = "My plot title"
)

Created on 2019-09-12 by the reprex package (v0.3.0)
The only idea I have so far would be to create a function that returns a list of both the custom labs and the custom theme. I am not entirely sure that is what I want either because I feel like that kind of goes against the feel of ggplot2.
So to be clear, I would prefer to be able to set it via something like:
theme(plot.title = element_text(fontcase = "upper"))
Any suggestions or ideas? Thanks!