R/check_aesthetics.R

Defines functions check_aesthetics

check_aesthetics <- function(x, n) {
  ns <- vapply(x, length, numeric(1))

  good <- ns == 1L | ns == n

  if (all(good)) {
    return()
  }

  stop(
    "Aesthetics must be either length 1 or the same as the data (",
    n, "): ", paste(names(!good), collapse = ", "), call. = FALSE
  )
}

Try the ggedit package in your browser

Any scripts or data that you put into this service are public.

ggedit documentation built on July 8, 2020, 5:34 p.m.