R/sgl_scale.R

Defines functions valid_scale.sgl_scale scale_name.sgl_scale new_sgl_scale

new_sgl_scale <- function(class = character()) {
  structure(
    list(),
    class = c(class, "sgl_scale")
  )
}

#' @export
scale_name.sgl_scale <- function(scale) {
  "base"
}

#' @export
valid_scale.sgl_scale <- function(scale, aes, layers, dfs) {
  mapped_aes_by_layer <- lapply(
    layers,
    function(layer) names(layer$aes_mappings)
  )
  all_mapped_aes <- unique(unlist(mapped_aes_by_layer))
  if (!(aes %in% all_mapped_aes)) {
    stop("Error: a scaled aesthetic must have at least one mapping")
  }
}

Try the rsgl package in your browser

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

rsgl documentation built on June 9, 2026, 1:07 a.m.