cells_stubhead()
Using a summarized version of the pizzaplace dataset, let’s create a gt table. Add a stubhead label with tab_stubhead() and then style it with tab_style() in conjunction with the use of cells_stubhead() in the locations argument.
pizzaplace
tab_stubhead()
tab_style()
locations
pizzaplace |> dplyr::mutate(month = as.numeric(substr(date, 6, 7))) |> dplyr::group_by(month, type) |> dplyr::summarize(sold = dplyr::n(), .groups = "drop") |> dplyr::filter(month %in% 1:2) |> gt(rowname_col = "type") |> tab_stubhead(label = "type") |> tab_style( style = cell_fill(color = "lightblue"), locations = cells_stubhead() )