Skip to contents

Italicize document titles in a table or figure

Usage

italicize_titles(x, col)

Arguments

x

A table data object created with tabulize() or a figure created with visualize()

col

The column to italicize

Value

A gt table data object or a ggplot2 figure

Examples

library(gt)
library(tmtyro)

penguins_gt <-
  penguins |>
  select(-year) |>
  summarize(
    across(
      matches("_len$|_dep$"), mean, na.rm = TRUE),
    .by = c(species, island, sex)) |>
  gt() |>
  fmt_number() |>
  tab_spanner(
    "bill",
    columns = starts_with("bill_")) |>
  tab_spanner(
    "flipper",
    starts_with("flip")) |>
  cols_label(
    bill_len = "length",
    bill_dep = "depth",
    flipper_len = "length") |>
  sub_missing()

penguins_gt |>
  collapse_rows(species) |>
  collapse_rows(island) |>
  italicize_titles(species)