R/nextLabel.R

Defines functions next_label

GREEK <- intToUtf8(c(913:929, 931:937), multiple = TRUE)
greek <- intToUtf8(c(945:961, 963:969), multiple = TRUE)

#' @importFrom utils as.roman
next_label <- function(figure)
{
  n <- length(figure$grobs) / 2 + 1L
  panelLabelType <- attr(figure, "multipanelfigure.panelLabelType")
  switch(
    panelLabelType,
    "upper-alpha" = LETTERS[n],
    "lower-alpha" = letters[n],
    "decimal"     = as.character(n),
    "upper-roman" = as.roman(n),
    "lower-roman" = tolower(as.roman(n)),
    "upper-greek" = GREEK[n],
    "lower-greek" = greek[n],
    "none"        = "",
    stop("The label type ", panelLabelType, " is not supported.")
  )
}

Try the multipanelfigure package in your browser

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

multipanelfigure documentation built on Nov. 27, 2023, 5:08 p.m.