The cells_footnotes() function

Using a subset of the sza dataset, let’s create a gt table. We’d like to color the sza column so that’s done with the data_color() function. We can add a footnote with tab_footnote() and we can also style the footnotes section. The styling is done with tab_style() and locations = cells_footnotes().

sza |>
  dplyr::filter(
    latitude == 20 &
      month == "jan" &
      !is.na(sza)
  ) |>
  dplyr::select(-latitude, -month) |>
  gt() |>
  data_color(
    columns = sza,
    palette = c("white", "yellow", "navyblue"),
    domain = c(0, 90)
  ) |>
  tab_footnote(
    footnote = "Color indicates height of sun.",
    locations = cells_column_labels(columns = sza)
  ) |>
  tab_options(table.width = px(320)) |>
  tab_style(
    style = list(
      cell_text(size = "smaller"),
      cell_fill(color = "gray90")
      ),
    locations = cells_footnotes()
  )
tst sza1
0700 84.9
0730 78.7
0800 72.7
0830 66.1
0900 61.5
0930 56.5
1000 52.1
1030 48.3
1100 45.5
1130 43.6
1200 43.0
1 Color indicates height of sun.