Context
I am making a table and saving it into Microsoft Word with .docx
file.
the table has a variable named PM2.5
. I want to subscript 2.5
like PM2.5.
In this answear, I can use the grammar 'PM~2.5~'
with as_kable()
to use subscrpit in PM2.5
.
But when I save the result (tab
), it is a blank .docx
file.
Question
How can I use subscripts in gtsummary and save it into .docx
file?
Reproducible code
library(dplyr)
library(gtsummary)
df = data.frame(PM2.5 = 1)
tab = # make a table using gtsummary
df %>%
tbl_summary(label = PM2.5 ~ 'PM~2.5~') %>% # subscript in main table
modify_table_styling(columns = label,
rows = label == 'PM~2.5~',
footnote = 'PM~2.5~ in footnote') %>% # subscript in footnote
as_kable()
tab %>% flextable::save_as_docx(path = 'test.docx') # a blank .docx file