1

I've been trying to name an R data frame columns with greek letters in order to call kable and get a latex output table with header names as these greek letters. The result is that kable does not recognise column names as the way latex greek letters are written, or the arguments are not passing to the function in the correct format.

A <- t(as.data.frame(seq(1:4)))
colnames(A) <- c("$\\\\alpha$", "$\\\\beta$", "$\\\\delta$", "$\\\\gamma$")
A %>%
  kable(.,"latex", escape = F, booktabs = T, linesep = "", align = "c")

Is there a way to do this propperly?

The best solution I,ve found so far is set column names of the data frame to NULL, and write the table headers form the knit options as follows:

A <- t(as.data.frame(seq(1:4)))
colnames(A) <- NULL
A %>%
  kable(., "latex", escape = F, booktabs = T, linesep = "", align = "c") %>% 
  add_header_above(c("$\\\\alpha$", "$\\\\beta$", "$\\\\delta$", "$\\\\gamma$"))

But this way is quite messy and lacks of automation.

Finally I tried the following and it doesn't work too.

A <- t(as.data.frame(seq(1:4)))
A %>%
  kable(., "latex", escape = F, booktabs = T, linesep = "", align = "c", col.names = c("$\alpha$", "$\beta$", "$\delta$", "$\gamma$"))

Thanks a lot.

PD: Here is the link to the issue on rmarkdown GitHub

0 Answers0