First time here, perhaps this is wrong, but I also posted my question on SO. Hope I'm not committing any major faux pas by posting in 2 locations, but was hoping more people might see my question.
the SO post : here
Question: how to insert linebreaks in the groupname_col of the gt() function
I have tried using a string with
, br(), \n without any luck.
I have also played with the row_group.sep parameter, but this still does not get the desired result
Is there a way to target the groupname_col portion of the table?
I know how to insert line breaks into regular columns with fmt_markdown, but can't apply to the group row labels
Here is an example of what I have tried
I would like my group rows to have a line break as indicated in the variable group_label
library(tidyverse) library(gt) df <- tibble( name = c("john", "john", "jerry", "jerry", "jack", "jack", "jim", "jim"), day = c("wed", "wed", "thurs", "thurs", "mon", "mon", "tues", "tues"), lotto = c(12, 42, 54, 57, 234, 556, 34, 23) ) df %>% mutate(group_label = paste(name, day, sep = "<br>")) %>% gt( groupname_col = "group_label", rowname_col = "day" ) %>% cols_hide( columns = vars(name) ) %>% fmt_markdown( columns = vars(group_label) )
I considered trying to apply line breaks to the gt_group_heading_row class after doing some investigating into the css, but I really am not sure how I would tackle that
Any help much appreciated!