Is there a way to export or knit a table directly to word-format in an R-script (instead of R-markdown)? knitr
and kableExtra
seem to provide a wide range of options to save tables, yet there is no option to export tables as actual word files.
library(tidyverse)
library(kableExtra)
dt <- mtcars[1:5, 1:6]
kbl(dt, caption="Table") %>%
kable_classic(full_width = F, html_font = "Cambria")
save_kable("my_latex_table.png") # alternatives: .jpg and .pdf, but not .doc
Since packages and functions such as htmlreg::texreg() allow you to write the output of statistical models into nicely formatted tables which you can then directly include into word documents, I would imagine that this should also be possible with simple tables (e.g. descriptive statistics). The thing is that I would like to export them directly in the format of a word table instead of an image.