Skip to contents

Allow user to define ggplot labels, and populate missing values from the defaults specified in labels formal argument.

Usage

matchLabels(labels, argName = "labels")

Arguments

labels

list. User-defined plot labels. Per element, supports character(1)., logical(1) (for automatic labels), or NULL.

argName

character(1). Argument name defined in formalArgs() to match against user input. Defaults to "labels".

Value

list. Returns an empty list on NULL input.

Note

Updated 2022-05-24.

See also

Examples

fun <- function(
    object,
    labels = list(
        "title" = NULL,
        "x" = "x-axis",
        "y" = "y-axis"
    )) {
    labels <- matchLabels(labels)
    labels
}