gginnards (version 0.0.1)

drop_vars: Drop unused variables from data

Description

Automatically remove unused variables from the data object embedded in a gg or ggplot object.

Usage

drop_vars(p, keep.vars = character(), guess.vars = TRUE)

Arguments

p

ggplot Plot object with embedded data.

keep.vars

character Names of unused variables to be kept.

guess.vars

logical Flag indicating whether to find used variables automatically.

Warning!

The current implementation drops variables only from the default data object. Data objects within layers are not modified.

Examples

Run this code
# NOT RUN {
library(ggplot2)

p <- ggplot(mpg, aes(factor(year), (cty + hwy) / 2)) +
  geom_boxplot() +
  facet_grid(. ~ class)
p

p.dp <- drop_vars(p)
p.dp

object.size(p)
object.size(p.dp)

names(p$data)
names(p.dp$data)

# }

Run the code above in your browser using DataLab