<-
tbl ::tibble(
dplyrrow = 1:6,
group = c(rep("Group A", 3), rep("Group B", 3)),
vals = 1:6
)
The row_group()
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). 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),
~ px(50)
vals )
vals | ||
---|---|---|
Group A | I | 1 |
II | 2 | |
III | 3 | |
Group B | IV | 4 |
V | 5 | |
VI | 6 |