The problem is that you are passing the title parameter as a fixed character string, you have to construct the string programmatically, this would be one way to do it
library(tidyverse)
library(rlang)
plot_func <- function(data, cat_var, measure){
ggplot({{data}}, aes(x = {{cat_var}}, y = {{measure}})) +
geom_boxplot() +
labs(title = str_to_title(paste("Boxplot of", as_string(ensym(measure)), "by", as_string(ensym(cat_var)))))
}
plot_func(starwars, gender, height)
