Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R - gt package - Ability to control cell padding within table header and column labels?

Tags:

r

gt

Problem
The gt package allows for a few cell padding parameters to be passed within tab_options(). For example, data_row.padding and footnotes.padding. However, there are no parameters available which affect the table header or column labels parts of the gt Table.

Question
Is there any way to control the cell padding within the table header or column labels parts of the gt Table?

Reproducible example with massive cell padding for demonstration:

gt_tbl <- gt(data = mtcars) %>% 
  tab_header(
     title = "mtcars dataset") %>% 
  tab_options(data_row.padding = px(35))

gt_tbl
like image 331
trippy Avatar asked Nov 03 '25 08:11

trippy


1 Answers

There are arguments within tab_options() for handling padding of the requested elements.

gt(data = mtcars) %>% 
  tab_header(
    title = "mtcars dataset") %>% 
  tab_options(data_row.padding = px(35), 
              column_labels.padding = px(35), 
              heading.padding = px(35))  
like image 87
Susan Switzer Avatar answered Nov 05 '25 23:11

Susan Switzer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!