Learn R Programming

thisplot (version 0.3.1)

get_vars: Get used vars in a ggplot object

Description

Get used vars in a ggplot object

Usage

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

Value

A character vector of variable names. If reverse is FALSE, returns used variables; if TRUE, returns unused variables.

Arguments

p

A ggplot object.

reverse

Whether to return unused vars. Default is FALSE.

verbose

Whether to print the message. Default is TRUE.

Examples

Run this code
library(ggplot2)
p <- ggplot(
  data = mtcars,
  aes(x = mpg, y = wt, colour = cyl)
) +
  geom_point()
get_vars(p)
get_vars(p, reverse = TRUE)

Run the code above in your browser using DataLab