Use exibble to create a gt table with all the main parts added. We can use this gt object going forward to demo some of what’s available in the tab_options() function.
tab_1 <- exibble |> dplyr::select(-c(fctr, date, time, datetime)) |>gt(rowname_col ="row",groupname_col ="group" ) |>tab_header(title =md("Data listing from **exibble**"),subtitle =md("`exibble` is an R dataset") ) |>fmt_number(columns = num) |>fmt_currency(columns = currency) |>tab_footnote(footnote ="Using commas for separators.",locations =cells_body(columns = num,rows = num >1000 ) ) |>tab_footnote(footnote ="Using commas for separators.",locations =cells_body(columns = currency,rows = currency >1000 ) ) |>tab_footnote(footnote ="Alphabetical fruit.",locations =cells_column_labels(columns = char) )tab_1
Data listing from exibble
exibble is an R dataset
num
char1
currency
grp_a
row_1
0.11
apricot
$49.95
row_2
2.22
banana
$17.95
row_3
33.33
coconut
$1.39
row_4
444.40
durian
2 $65,100.00
grp_b
row_5
2 5,550.00
NA
2 $1,325.81
row_6
NA
fig
$13.26
row_7
2 777,000.00
grapefruit
NA
row_8
2 8,880,000.00
honeydew
$0.44
1 Alphabetical fruit.
2 Using commas for separators.
Modify the table width to be 100% (which spans the entire content width area).
tab_1 |>tab_options(table.width =pct(100))
Data listing from exibble
exibble is an R dataset
num
char1
currency
grp_a
row_1
0.11
apricot
$49.95
row_2
2.22
banana
$17.95
row_3
33.33
coconut
$1.39
row_4
444.40
durian
2 $65,100.00
grp_b
row_5
2 5,550.00
NA
2 $1,325.81
row_6
NA
fig
$13.26
row_7
2 777,000.00
grapefruit
NA
row_8
2 8,880,000.00
honeydew
$0.44
1 Alphabetical fruit.
2 Using commas for separators.
Modify the table’s background color to be "lightcyan".