Get used vars in a ggplot object
Value
A character vector of variable names.
If reverse is FALSE, returns used variables;
if TRUE, returns unused variables.
Examples
library(ggplot2)
p <- ggplot(
data = mtcars,
aes(x = mpg, y = wt, colour = cyl)
) +
geom_point()
get_vars(p)
#> ℹ [2025-12-10 13:54:21] Vars_used: "mpg", "cyl", and "wt"
#> ℹ vars_notused: "disp", "hp", "drat", "qsec", "vs", "am", "gear", and "carb"
#> [1] "mpg" "cyl" "wt"
get_vars(p, reverse = TRUE)
#> ℹ [2025-12-10 13:54:21] Vars_used: "mpg", "cyl", and "wt"
#> ℹ vars_notused: "disp", "hp", "drat", "qsec", "vs", "am", "gear", and "carb"
#> [1] "disp" "hp" "drat" "qsec" "vs" "am" "gear" "carb"