Use a subset of the sp500 dataset to create a gt table. We want all the column labels to be entirely capitalized versions of the default labels but, instead of using cols_label() and rewriting each label manually in capital letters we can use cols_label_with() and instruct it to apply the toupper() function to all column labels.
sp500 |> dplyr::filter( date >="2015-12-01"& date <="2015-12-15" ) |> dplyr::select(-c(adj_close, volume)) |>gt() |>cols_label_with(fn = toupper)
DATE
OPEN
HIGH
LOW
CLOSE
2015-12-15
2025.55
2053.87
2025.55
2043.41
2015-12-14
2013.37
2022.92
1993.26
2021.94
2015-12-11
2047.27
2047.27
2008.80
2012.37
2015-12-10
2047.93
2067.65
2045.67
2052.23
2015-12-09
2061.17
2080.33
2036.53
2047.62
2015-12-08
2073.39
2073.85
2052.32
2063.59
2015-12-07
2090.42
2090.42
2066.78
2077.07
2015-12-04
2051.24
2093.84
2051.24
2091.69
2015-12-03
2080.71
2085.00
2042.35
2049.62
2015-12-02
2101.71
2104.27
2077.11
2079.51
2015-12-01
2082.93
2103.37
2082.93
2102.63
Use the countrypops dataset to create a gt table. To improve the presentation of the table, we are again going to change the default column labels via function calls supplied within cols_label_with(). We can, if we prefer, apply multiple types of column label changes in sequence with multiple calls of cols_label_with(). Here, we use the make_clean_names() functions from the janitor package and follow up with the removal of a numeral with gsub().
We can make a svelte gt table with the pizzaplace dataset. There are ways to use one instance of cols_label_with() with multiple functions called on the column labels. In the example, we use an anonymous function call (with the function(x) { ... } construction) to perform multiple mutations of x (the vector of column labels). We can even use the md() helper function with that to signal to gt that the column label should be interpreted as Markdown text.