str_mk: markdown superscript and subscript

View source: R/str_format.R

str_mkR Documentation

markdown superscript and subscript

Description

markdown superscript and subscript

Usage

str_mk(x)

label_mk(labels, ...)

Arguments

x

character vector

labels

character vector

...

ignored

Author(s)

Dongdong Kong

Examples

x <- c(
  "gC m^{-2} d^{-1}",
  "gC m^-2 d^-1",
  "gC m_{-2} d_{-1}",
  "gC m_-2 d_-1",
  "gC \n mm/d"
)
str_mk(x)
## use str_mk in ggplot
library(ggplot2)

d <- data.frame(
  x = 1:3, y = 1:3,
  varname = c("T_min", "T_max", "T_avg")
)

ggplot(d, aes(x, y)) +
  geom_point() +
  geom_richtext(aes(label = varname), x = 2, y = 2) +
  facet_wrap(~varname, labeller = label_mk) +
  theme(
    strip.text = element_markdown(face = "bold")
  )

rpkgs/gg.layers documentation built on Sept. 14, 2024, 11:07 p.m.