在Rmarkdown中隐藏stepAIC的输出

在Rmarkdown中隐藏stepAIC的输出,r,r-markdown,R,R Markdown,如何最好地将stepAIC的输出隐藏在Rmarkdown中的输出中。 我尝试了echo=FALSE,message=FALSE,但不起作用。有什么线索吗 --- title: "Multivariate Regression" author: "Moses Otieno" date: "11/05/2021" output: word_document --- ```{r setup, include=FALSE} knitr::op

如何最好地将stepAIC的输出隐藏在Rmarkdown中的输出中。 我尝试了
echo=FALSE
message=FALSE
,但不起作用。有什么线索吗

---
title: "Multivariate Regression"
author: "Moses Otieno"
date: "11/05/2021"
output: word_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, message = FALSE, warning = FALSE)

library(gtsummary) # Grammar of tables 

```

```{r regression}
mod1 <- glm(response ~ trt + age + grade , trial, family = binomial)

step.model <- MASS::stepAIC(mod1, direction = "both")

t1 <- tbl_regression(step.model, exponentiate = TRUE)
t1
```
---
标题:“多元回归”
作者:“摩西·奥蒂诺”
日期:“2021年5月11日”
输出:word\u文档
---
```{r设置,include=FALSE}
knitr::opts_chunk$set(echo=FALSE,message=FALSE,warning=FALSE)
图书馆(gtsummary)#表格语法
```
```{r回归}

mod1Set
trace=0
?从
?MASS::stepAIC

跟踪:如果为正,则在运行时打印信息 “stepAIC”。较大的值可能会提供有关 拟合过程

这是最好的方法,但是如果您不能做到这一点,那么
capture.output()
也可以:


这真是太棒了。我把它封装在一个函数中,这样跟踪组件就可以很好地工作了。其他选择也不错。这帮了大忙。