gt rowname_col show only one entry vertically centered
03:27 18 Sep 2026

I have the following df I would like to represent as a gt table in R.

df <- structure(list(method = c("GT", "GT", "GT", "GT", "GT", "BASEPAIR", 
"BASEPAIR", "BASEPAIR", "BASEPAIR", "BASEPAIR", "GT", "GT", "GT", 
"GT", "GT", "BASEPAIR", "BASEPAIR", "BASEPAIR", "BASEPAIR", "BASEPAIR", 
"GT", "GT", "GT", "GT", "GT", "BASEPAIR", "BASEPAIR", "BASEPAIR", 
"BASEPAIR", "BASEPAIR", "GT", "GT", "GT", "GT", "GT", "BASEPAIR", 
"BASEPAIR", "BASEPAIR", "BASEPAIR", "BASEPAIR"), variant_type = c("ALL", 
"Snv", "Insertion", "Deletion", "JointIndel", "ALL", "Snv", "Insertion", 
"Deletion", "JointIndel", "ALL", "Snv", "Insertion", "Deletion", 
"JointIndel", "ALL", "Snv", "Insertion", "Deletion", "JointIndel", 
"ALL", "Snv", "Insertion", "Deletion", "JointIndel", "ALL", "Snv", 
"Insertion", "Deletion", "JointIndel", "ALL", "Snv", "Insertion", 
"Deletion", "JointIndel", "ALL", "Snv", "Insertion", "Deletion", 
"JointIndel"), approach = c("graph", "graph", "graph", "graph", 
"graph", "graph", "graph", "graph", "graph", "graph", "graph", 
"graph", "graph", "graph", "graph", "graph", "graph", "graph", 
"graph", "graph", "linear", "linear", "linear", "linear", "linear", 
"linear", "linear", "linear", "linear", "linear", "linear", "linear", 
"linear", "linear", "linear", "linear", "linear", "linear", "linear", 
"linear"), technology = c("PacBio", "PacBio", "PacBio", "PacBio", 
"PacBio", "PacBio", "PacBio", "PacBio", "PacBio", "PacBio", "Illumina", 
"Illumina", "Illumina", "Illumina", "Illumina", "Illumina", "Illumina", 
"Illumina", "Illumina", "Illumina", "PacBio", "PacBio", "PacBio", 
"PacBio", "PacBio", "PacBio", "PacBio", "PacBio", "PacBio", "PacBio", 
"Illumina", "Illumina", "Illumina", "Illumina", "Illumina", "Illumina", 
"Illumina", "Illumina", "Illumina", "Illumina"), F1 = c(0.851675933284153, 
0.921019040390317, 0.762758227318656, 0.489127006306561, 0.59682859741513, 
0.523882959480172, 0.919441902935077, 0.417099501783567, 0.359939157227847, 
0.386876595244985, 0.867621989385044, 0.884716959168713, 0.80869042462063, 
0.79044532280396, 0.799518211113192, 0.447743435757733, 0.881276255986441, 
0.280087436609624, 0.277791741880202, 0.278883134534967, 0.849148312386456, 
0.851919223209642, 0.841128770949849, 0.833569630459964, 0.837252629646706, 
0.471659906649248, 0.849955213723214, 0.359558090878969, 0.302944567010914, 
0.330387390040813, 0.731835572928325, 0.740608398257377, 0.698832860858598, 
0.694613888338913, 0.696713412406233, 0.341470247477517, 0.733297299014185, 
0.195517852122517, 0.199446742223383, 0.197582386734749), Highest = c("graph_sr", 
"graph_lr", "na", "na", "linear_lr", "graph_lr", "graph_lr", 
"na", "na", "linear_lr", "graph_sr", "graph_lr", "na", "na", 
"linear_lr", "graph_lr", "graph_lr", "na", "na", "linear_lr", 
"graph_sr", "graph_lr", "na", "na", "linear_lr", "graph_lr", 
"graph_lr", "na", "na", "linear_lr", "graph_sr", "graph_lr", 
"na", "na", "linear_lr", "graph_lr", "graph_lr", "na", "na", 
"linear_lr")), row.names = c(NA, -40L), class = "data.frame")

Now, I'm pretty much satisfied with what I got; however, the rowname_col shows the same value/string repeated ten times for each technology across approaches.

This is a bit redundant and I was hoping to have displayed only once, vertically centered for each approach for the two different technologies. Is there a way to do so? Below, the code I'm using and associated output (with the desired edits to be made):

library(gt)
library(dplyr)
library(purrr)

gt(df, rowname_col = "approach", groupname_col = "technology", row_group_as_column = TRUE) |>
  data_color(
    method = "numeric",
    palette = "viridis",
    reverse = T
  ) |>
  tab_row_group(
    label = "long reads",
    rows = technology == "PacBio",
  ) |>
  tab_style(
    style = cell_text(style = "italic", v_align = "middle", align = "center"),
    locations = cells_stub()
  ) |>
  tab_style(
    style = cell_text(weight = "bold", v_align = "middle", align = "center"),
    locations = cells_column_labels(columns = everything())
  ) |>
   tab_style(
    style = cell_text(weight = "lighter", v_align = "middle", align = "center", whitespace = "pre-wrap"),
    locations = cells_row_groups()
  ) |>
  cols_label(
    variant_type = "variant
type", Highest = "highest", .fn = md ) |> text_replace( pattern = "^Illumina$", replacement = "short reads", locations = cells_row_groups() ) |> tab_options(table.width = pct(80))

table_ex

r gt r-rownames