Skip to contents

Replace NULL output.type based on geom and validate other values. Convert synonyms and change into lower case mal-formed input.

Usage

check_output_type(
  output.type,
  geom = "text",
  supported.types = c("expression", "text", "markdown", "marquee", "numeric", "latex",
    "latex.eqn", "latex.deqn")
)

Arguments

output.type

character User-set argument or default from stat

geom

character The name of the geom that will be used to render the labels.

supported.types

character vector of accepted values for user input.

Value

If output.type is NULL a suitable value based on the name of the geom is returned, defaulting to "expression". If not NULL, the value is passed through unchanged.

Output types

The formatting of character strings to be displayed in plots are marked as mathematical equations. Depending on the geom used, the mark-up needs to be encoded differently, or in some cases mark-up not applied.

"expression"

The labels are encoded as character strings to be parsed into R's plotmath expressions.

"LaTeX", "TeX", "tikz", "latex"

The labels are encoded as 'LaTeX' maths equations, without the "fences" for switching in math mode.

"latex.eqn"

Same as "latex" but enclosed in single $, i.e., as in-line maths.

"latex.deqn"

Same as "latex" but enclosed in double $$, i.e., as display maths.

"markdown"

The labels are encoded as character strings using markdown syntax, with some embedded HTML.

"marquee"

The labels are encoded as character strings using markdown syntax, with 'marquee' supported spans.

"text"

The labels are plain ASCII character strings.

"numeric"

No labels are generated. This value is accepted by the statistics, but not by the label formatting functions.

NULL

The value used, expression, latex.eqn or markup depends on the argument passed to geom.

If geom = "latex" (package 'xdvir') the output type used is "latex.eqn". If geom = "richtext" (package 'ggtext') or geom = "textbox" (package 'ggtext') the output type used is "markdown". If geom = "marquee" (package 'marquee') the output type used is "marquee". For all other values of geom the default is "expression" unless the user passes an argument. Invalid values as argument trigger an Error.

Examples

check_output_type(NULL)
#> [1] "expression"
check_output_type("text")
#> [1] "text"
check_output_type(NULL, geom = "text")
#> [1] "expression"
check_output_type(NULL, geom = "latex")
#> [1] "latex.eqn"