Let's assume I have the following R function:
library(tidyverse)
f <- function(.df, .var) {
.df %>% ggplot(aes(x = wt, y = {{ .var }})) +
geom_point() +
ggtitle({{ .var }})
}
f(mtcars, hp)
#> Error in list2(..., title = title, subtitle = subtitle, caption = caption, : object 'hp' not found
f(mtcars, qsec)
#> Error in list2(..., title = title, subtitle = subtitle, caption = caption, : object 'qsec' not found
Created on 2021-01-08 by the reprex package (v0.3.0)
How do I access the actual string that .var
takes to use when creating a title?