Use a subset of the sp500 dataset to create a gt table. Transform the text in the date column using a function supplied to text_transform() (via the fn argument). Note that the x in the fn = function (x) part consists entirely of ISO 8601 date strings (which are acceptable as input to vec_fmt_date() and vec_fmt_datetime()).
Let’s use a summarized version of the gtcars dataset to create a gt table. First, the numeric values in the n column are formatted as spelled-out numbers with fmt_spelled_num(). The output values are indeed spelled out but exclusively with lowercase letters. We actually want these words to begin with a capital letter and end with a period. To make this possible, text_transform() will be used since it can modify already-formatted text. Through the fn argument, we provide a custom function that uses R’s toTitleCase() operating on x (the numbers-as-text strings) within paste0() so that a period can be properly placed.
There may be occasions where you’d want to remove all text. Here in this example based on the pizzaplace dataset, we generate a gt table that summarizes an entire year of data by colorizing the daily sales revenue. Individual cell values are not needed here (since the encoding by color suffices), so, text_transform() is used to turn every value to an empty string: "".