Learn R Programming

avstrat (version 0.1.1)

validate_stratpal: Validate a stratigraphic palette

Description

Ensures that a palette covers all required categories. By default, missing categories trigger an error. If allow_na = TRUE, missing categories are filled with a default color instead.

Usage

validate_stratpal(pal, allow_na = FALSE, na_color = "gray90")

Value

A complete palette (named character vector) ordered to match the required categories.

Arguments

pal

Named character vector of colors.

allow_na

Logical. If TRUE, missing categories are filled with na_color instead of erroring.

na_color

Color to use for missing categories when allow_na = TRUE.

Examples

Run this code
# A complete palette passes validation
validate_stratpal(stratpal_rpg)

# Allow missing categories to be filled with gray
validate_stratpal(stratpal_grays, allow_na = TRUE)

Run the code above in your browser using DataLab