get_vars: Get used vars in a ggplot object

View source: R/utils.R

get_varsR Documentation

Get used vars in a ggplot object

Description

Get used vars in a ggplot object

Usage

get_vars(p, reverse = FALSE, verbose = TRUE)

Arguments

p

A ggplot object.

reverse

Whether to return unused vars. Default is FALSE.

verbose

Whether to print the message. Default is TRUE.

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)
get_vars(p, reverse = TRUE)

thisplot documentation built on March 7, 2026, 5:07 p.m.