8

I am creating a table using the gt package in R Studio, and I can't figure out a graceful way to make the columns more readable for tables with many rows.

Take the following code:

gt::sp500 %>% slice(1:100) %>%
  mutate(month = lubridate::month(date)) %>%
  group_by(month) %>%
  gt::gt(rowname_col = "date")

As you see below, the columns are visible through the first ~35 rows... enter image description here

But once you move beyond that, I find myself having to scroll up to remember which column is high and which is low, and whether adjusted close is in the 6th column or the 4th. Is there a way to either freeze those columns in place as you scroll (using the gt package), or easily repeat the column headers after each group (without messing with the underlying data)?

enter image description here

BSHuniversity
  • 264
  • 1
  • 6
  • I believe at the moment there is no function in {gt} that allows for repeating headers easily. This issue on the topic might be helpful: https://github.com/rstudio/gt/issues/194. The {kable} package does a better job of repeating headers if you are interested. – Edgar Zamora Feb 16 '22 at 17:48

0 Answers0