'Missing diacritics in GT table output

I am using GT package in R to create tables for my diploma thesis and I ran into a problem. The diploma is to be written in the czech language.

When GT draws the table it does not display the letter ě properly and shows e instead.

The code for GT table:

desc_sex[,2:ncol(desc_sex)] %>% gt(rowname_col = "sex"
  ) %>% tab_stubhead(
    label = html("Kategorie")
  ) %>% cols_align(
    align = "center",
    columns = everything()
  ) %>% cols_label(
    n = html("n"),
    procent = html("%")
  ) %>% tab_row_group(
    label = html("<b>Sledované regiony celkem"),
    rows = 7:9
  ) %>% tab_row_group(
    label = html("<b>Krajský soud v Ostravě"),
    rows = 4:6
  ) %>% tab_row_group(
    label = html("<b>Městský soud v Praze"),
    rows = 1:3
  ) %>% summary_rows(
    groups = T,
    fns = list(
      Celkem = ~sum(.)),
    formatter = fmt_number,
    decimals = 0
  )

Here are the data in CSV compliant format:

"reg_reside","sex","n","procent","single"
"MSPH","Muž",93,46.5,52
"MSPH","Žena",83,41.5,34
"MSPH","Manželský pár",24,12,0
"KSOS","Muž",113,56.5,51
"KSOS","Žena",68,34,30
"KSOS","Manželský pár",19,9.5,0
"Celkem","Muž",206,51.5,103
"Celkem","Žena",151,37.8,64
"Celkem","Manželský pár",43,10.8,0

Here is how the output looks in GT - the mistake is in Ostrave (should be Ostravě) and Mestsky (should be Městský):

Output from GT



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source