From 57e7d840ae9f716d4201e04929aed7fa82536650 Mon Sep 17 00:00:00 2001 From: mrcaseb Date: Fri, 13 Dec 2024 14:27:23 +0100 Subject: [PATCH] gt article column spanners --- vignettes/articles/gt.Rmd | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/vignettes/articles/gt.Rmd b/vignettes/articles/gt.Rmd index c8d281f..d1d4829 100644 --- a/vignettes/articles/gt.Rmd +++ b/vignettes/articles/gt.Rmd @@ -105,6 +105,35 @@ example_table |> nflplotR::gt_nfl_wordmarks(locations = gt::cells_stub()) ``` +### Column Spanners + +We use another table to demonstrate how to convert team names to logos and wordmarks in column spanners. + +Here only logos + +```{r} +df <- data.frame(a = 3, b = 4, c = 5, d = 6) + +df |> + gt::gt() |> + gt::tab_spanner("KC", c(a, b)) |> + gt::tab_spanner("LAC", c(c, d)) |> + nflplotR::gt_nfl_logos(locations = gt::cells_column_spanners()) +``` + +And now mix logo and wordmark + +```{r} +df <- data.frame(a = 3, b = 4, c = 5, d = 6) + +df |> + gt::gt() |> + gt::tab_spanner("KC", c(a, b)) |> + gt::tab_spanner("LAC", c(c, d)) |> + nflplotR::gt_nfl_logos(locations = gt::cells_column_spanners("KC")) |> + nflplotR::gt_nfl_wordmarks(locations = gt::cells_column_spanners("LAC")) +``` + ### Combine all together The `locations` argument allows multiple locations in one call by wrapping them in a list.