The cells_body() function

Let’s use a subset of the gtcars dataset to create a gt table. Add a footnote (with tab_footnote()) that targets a single data cell via the use of cells_body() in locations (rows = hp == max(hp) will target a single row in the hp column).

gtcars |>
  dplyr::filter(ctry_origin == "United Kingdom") |>
  dplyr::select(mfr, model, year, hp) |>
  gt() |>
  tab_footnote(
    footnote = "Highest horsepower.",
    locations = cells_body(
      columns = hp,
      rows = hp == max(hp)
    ),
    placement = "right"
  ) |>
  opt_footnote_marks(marks = c("*", "+"))
mfr model year hp
Bentley Continental GT 2016 500
Aston Martin DB11 2017 608
Aston Martin Rapide S 2016 552
Aston Martin Vanquish 2016 568
Aston Martin Vantage 2016 430
Lotus Evora 2017 400
Jaguar F-Type 2016 340
McLaren 570 2016 570
Rolls-Royce Dawn 2016 563
Rolls-Royce Wraith 2016 624*
* Highest horsepower.