is_any_layer_class: Check ggplot layers for use of a specific geom

View source: R/0_util.r

is_any_layer_classR Documentation

Check ggplot layers for use of a specific geom

Description

Checks if any of the layers of a ggplot contain a specific class.

Usage

is_any_layer_class(ggplot, class_nm = "GeomDensity")

Arguments

ggplot

Check the layers of this ggplot object

class_nm

The class name to check, note this differs slightly from the name of the geom function. Defaults to "GeomDensity", checking to see if geom_density was used in any of the layers.

See Also

ggplot2::theme for all theme options.

Examples

library(ggplot2)
library(spinifex)

g <- ggplot(mtcars, aes(disp, color = factor(cyl))) + 
  geom_density() + geom_histogram()
is_any_layer_class(g, "GeomDensity")
is_any_layer_class(g, "GeomPoint")

nspyrison/spinifex documentation built on Feb. 7, 2024, 1:10 p.m.