In gt, I'm trying to make a column label which is a Greek letter. The documentation mentions using the notation such as ":alpha:" but I'm not able to get this to work.
library(gt)
tab <- countrypops |>
dplyr::select(-contains("code")) |>
dplyr::filter(
country_name == "Uganda",
year %in% 2017:2021
) |>
gt() |>
cols_label(
country_name = ":alpha:",
year = md(":alpha:"),
population = md("$\\alpha$")
)
This is what I get:
1 Like
I think this does it, if I understand the problem.
DT1 |> gt() |>
cols_label(
country_name= md("$\\alpha$"),
year = md("$\\beta$"),
population = md("$\\gamma$")
)
I'm wondering how to use the syntax provided in the documentation of ":alpha:". I know how to do it with LaTeX.
Greek letters can added by enclosing the letter name in ":"; you can use lowercase letters (e.g., ":beta:", ":sigma:", etc.) and uppercase letters too (e.g., ":Alpha:", ":Zeta:", etc.)
1 Like
It works for me with "{{:alpha:}}". The double brackets signify the "units definition".
2 Likes
@ kevbaer has it. I just worked it out a few moments ago.
The problem seems to be some rather poorly written text in the manuals. It took me about 4 readings before I realized that :alpha: will only work in a units definition. The manuals are not wrong just obscure.
Yes, thanks. I was trying to RTFM and I just wasn't getting it.