row_group: Select helper for targeting the row group column

View source: R/helpers.R

row_groupR Documentation

Select helper for targeting the row group column

Description

Should you need to target only the row group column for column-width declarations (i.e., when row_group_as_column = TRUE is set in the initial gt() call), the row_group() select helper can be used. This shorthand makes it so you don't have to use the name of the column that was selected as the row group column.

Usage

row_group()

Value

A character vector of class "row_group_column".

Examples

Create a tibble that has a row column (values from 1 to 6), a group column, and a vals column (containing the same values as in row).

tbl <-
  dplyr::tibble(
    row = 1:6,
    group = c(rep("Group A", 3), rep("Group B", 3)),
    vals = 1:6
  )

Create a gt table with a two-column stub (incorporating the row and group columns in that). We can set the widths of the two columns in the stub with the row_group() and stub() helpers on the LHS of the expressions passed to cols_width().

tbl |>
  gt(
    rowname_col = "row",
    groupname_col = "group",
    row_group_as_column = TRUE
  ) |>
  fmt_roman(columns = stub()) |>
  cols_width(
    row_group() ~ px(200),
    stub() ~ px(100),
    vals ~ px(50)
  )
This image of a table was generated from the first code example in the `row_group()` help file.

Function ID

8-11

Function Introduced

v0.11.0

See Also

Other helper functions: adjust_luminance(), cell_borders(), cell_fill(), cell_text(), currency(), default_fonts(), escape_latex(), from_column(), google_font(), gt_latex_dependencies(), html(), md(), nanoplot_options(), pct(), px(), random_id(), stub(), system_fonts(), unit_conversion()


gt documentation built on Sept. 11, 2024, 5:15 p.m.