Saves a collection of gtsummary tables and ggplot2 plots into a .docx file.
Examples
# \donttest{
library(gtsummary)
library(ggplot2)
tbl <- tbl_regression(glm(mpg ~ hp + wt, data = mtcars))
p <- ggplot(mtcars, aes(x = wt, y = mpg)) +
geom_point()
save_docx(
tables = list(tbl),
plots = list(p),
filename = file.path(tempdir(), "report.docx"),
titles = c("Table 1: Regression", "Figure 1: Scatterplot")
)
#> Word document saved at: /tmp/Rtmp9h6NFv/report.docx
#> If tables or plots extend beyond the page, consider switching to landscape layout in Word (Layout > Orientation > Landscape).
# }