n_layers: How many layers are in a plot?

View source: R/layers.R

n_layersR Documentation

How many layers are in a plot?

Description

How many layers are in a plot?

Usage

n_layers(p)

Arguments

p

A ggplot object

Value

Numeric. The number of layers.

Examples

require(ggplot2)
p <- ggplot(data = mpg, mapping = aes(x = displ, y = hwy)) +
  geom_point(mapping = aes(color = class)) +
  geom_smooth()
n_layers(p)

rstudio-education/ggcheck documentation built on May 12, 2023, 11:33 a.m.