Using flextable
to make a table, I would like a column heading to be pi (with a hat) and an i subscript. With flextable
6 I see that I can add basic formatting to titles using the compose()
function. I can get pi sub i easily but I don't see how to put the hat over the pi.
test <- data.frame(hat_pi_i= c(0.1, 0.9))
# devtools::install_github("davidgohel/flextable") # version 6.x
# devtools::install_github("davidgohel/officer") # for flextable 6 to work
library(flextable)
# compose conflicts with purrr & igraph
flextable(test) %>%
compose(part = "header", j = "hat_pi_i",
value = as_paragraph("hat π", as_sub("i")))
Is it possible to tweak the title above to put the hat on the pi instead of as a word next to it?
There's a hackish way to do it:
flextable(test) %>%
compose(part = "header", j = "hat_pi_i",
value = as_paragraph("\U1D70B\U0302", as_sub("i")))
This uses Unicode characters: \U1D70B
is the math style pi, and \U0302
says to put a circumflex on the previous character. You could also do the first char with π
, but it doesn't look as good, because (at least on my system) the circumflex ends up misplaced: