由于sjPlot
输出为 html,因此很难将其直接放入 Word 文档中。knitr
这是一个示例,说明如何使用、rmarkdown
、jtools
和来执行与您想要执行的操作类似的操作huxtable
。我将 RStudio 与 rmarkdown 文档一起使用,我将其编入 Word 文档。
---
title: "jtools to Output Logistic Regression Models"
author: "sar"
date: "`r format(Sys.time(), '%d %B %Y')`"
output: word_document
---
```{r setup, include=FALSE}
library(knitr)
library(jtools)
library(huxtable)
knitr::opts_chunk$set(echo=FALSE, warning = FALSE)
```
# Introduction
This is a test document to demonstrate how knitr and rmarkdown can be used to put output from jtools
into a Word Document
```{r OutputTable}
set.seed(1234)
logistic_s <- data.frame(N=rbinom(200,1,0.5),
G=rbinom(200,1,0.5),
G_1=rbinom(200,1,0.5),
L_1=rbinom(200,1,0.5),
C_1=rbinom(200,1,0.5),
m=rbinom(200,1,0.5),
Age_2=round(rnorm(200,40,6)))
n1 <- glm(N ~ Age_2 , data = logistic_s, family = "binomial")
g1 <- glm(G ~ Age_2 , data = logistic_s, family = "binomial")
ga1 <- glm(G_1 ~ Age_2 , data = logistic_s, family = "binomial")
l1 <- glm(L_1 ~ Age_2 , data = logistic_s, family = "binomial")
c1 <- glm(C_1 ~ Age_2 , data = logistic_s, family = "binomial")
m1 <- glm(m ~ Age_2 , data = logistic_s, family = "binomial")
model_summs <- export_summs(n1,g1,ga1,l1,c1,m1,
error_format = "({conf.low}, {conf.high})",
model.names = c("N","G","G_1","L_1","C_1","m"))
col_width(model_summs) = c(0.84,rep(0.95,6))
model_summs
```