tbl <-
dplyr::tibble(
row = 1:6,
group = c(rep("Group A", 3), rep("Group B", 3)),
vals = 1:6
)The stub() function
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).
Create a gt table with a two-column stub (incorporating the row and group columns in that). Format the row labels of the stub with fmt_roman() to obtain Roman numerals in the stub; we’re selecting the stub column here with the stub() select helper.
tbl |>
gt(rowname_col = "row", groupname_col = "group") |>
fmt_roman(columns = stub()) |>
tab_options(row_group.as_column = TRUE)| vals | ||
|---|---|---|
| Group A | I | 1 |
| II | 2 | |
| III | 3 | |
| Group B | IV | 4 |
| V | 5 | |
| VI | 6 | |