如何在 Rmarkdown 中制作表格作为 Word
How to make tables in Rmarkdown as Word
我试图在 Rmarkdown 中包含一个在 Word 中看起来像的 table。这就是我在 Word 中得到 table 的方式:
有什么方法可以将这个 table 与 Rmardown 文档中的图像完全一样?
从文档中获取 table 的屏幕截图并使用

如果我们想从模型对象创建 table 使用 gtsummary
或 flextable
library(gtsummary)
library(flextable)
data(trial)
model <- glm(response ~ trt, trial, family = binomial)
tbl_regression(model)
as_flextable(model)
根据显示的格式,crosstable
也可以
library(crosstable)
crosstable(ggplot2::mpg, class, by = drv) %>%
crosstable::as_flextable()
我试图在 Rmarkdown 中包含一个在 Word 中看起来像的 table。这就是我在 Word 中得到 table 的方式:
有什么方法可以将这个 table 与 Rmardown 文档中的图像完全一样?
从文档中获取 table 的屏幕截图并使用

如果我们想从模型对象创建 table 使用 gtsummary
或 flextable
library(gtsummary)
library(flextable)
data(trial)
model <- glm(response ~ trt, trial, family = binomial)
tbl_regression(model)
as_flextable(model)
根据显示的格式,crosstable
也可以
library(crosstable)
crosstable(ggplot2::mpg, class, by = drv) %>%
crosstable::as_flextable()