The cells_column_spanners()
function
Use exibble
to create a gt table. Add a spanner column label over three column labels with tab_spanner()
and then use tab_style()
and cells_column_spanners()
to make the spanner label text bold.
exibble |>
dplyr:: select (- fctr, - currency, - group) |>
gt (rowname_col = "row" ) |>
tab_spanner (
label = "dates and times" ,
columns = c (date, time, datetime),
id = "dt"
) |>
tab_style (
style = cell_text (weight = "bold" ),
locations = cells_column_spanners (spanners = "dt" )
)
num
char
dates and times
date
time
datetime
row_1
1.111e-01
apricot
2015-01-15
13:35
2018-01-01 02:22
row_2
2.222e+00
banana
2015-02-15
14:40
2018-02-02 14:33
row_3
3.333e+01
coconut
2015-03-15
15:45
2018-03-03 03:44
row_4
4.444e+02
durian
2015-04-15
16:50
2018-04-04 15:55
row_5
5.550e+03
NA
2015-05-15
17:55
2018-05-05 04:00
row_6
NA
fig
2015-06-15
NA
2018-06-06 16:11
row_7
7.770e+05
grapefruit
NA
19:10
2018-07-07 05:22
row_8
8.880e+06
honeydew
2015-08-15
20:20
NA