check-scalar-isGgscale: Does the input contain a ggplot2 scale?

check-scalar-isGgscaleR Documentation

Does the input contain a ggplot2 scale?

Description

Does the input contain a ggplot2 scale?

Usage

isGgscale(
  x,
  scale = c("continuous", "discrete"),
  aes = c("color", "colour", "fill"),
  nullOk = FALSE
)

Arguments

x

Object.

scale

character(1). Type of scale, either "continuous" or "discrete".

aes

character(1). Aesthetic mapping, either "color"/"colour" or "fill". Note that ggplot2 prefers British spelling.

nullOk

logical(1). If set to TRUE, x may also be NULL.

Value

TRUE on success; FALSE on failure, with cause set.

Note

Updated 2019-09-14.

Examples

library(ggplot2)

color_c <- scale_color_gradient(low = "red", high = "blue")
class(color_c)

color_d <- scale_color_manual(values = c("red", "blue"))
class(color_d)

fill_c <- scale_fill_gradient(low = "red", high = "blue")
class(fill_c)

fill_d <- scale_fill_manual(values = c("red", "blue"))
class(fill_d)

isGgscale(x = color_c, scale = "continuous", aes = "color")
isGgscale(x = color_d, scale = "discrete", aes = "color")
isGgscale(x = fill_c, scale = "continuous", aes = "fill")
isGgscale(x = fill_d, scale = "discrete", aes = "fill")

acidgenomics/r-goalie documentation built on Jan. 12, 2024, 4:15 a.m.