p <- ggplot(mpg, aes(factor(year), (cty + hwy) / 2)) +
geom_boxplot() +
geom_point(color = "red") +
facet_grid(. ~ class) +
ggtitle("Example plot")
p
# str(p) vs. summary(p)
str(p)
summary(p) # from pacakge 'ggplot2'
# structure of p at 2 levels of nesting
str(p, max.level = 2, size = FALSE)
# top level structure and size of p
str(p, max.level = 0)
# names of ggplot members
names(p)
# structure and size of p["data"]
str(p, max.level = 2, components = "data")
# structure and size of p["layers"]
str(p, max.level = 1, components = "layers")
Run the code above in your browser using DataLab