r - Hiding output of stepAIC in Rmarkdown
问题描述
How best will I hide the output of stepAIC from the output in the Rmarkdown.
I tried echo = FALSE
, message = FALSE
but it would not work. Any leads kindly?
---
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
```
解决方案
设置trace=0
?从?MASS::stepAIC
,
trace:如果为正,则在“stepAIC”运行期间打印信息。较大的值可能会提供有关拟合过程的更多信息。
这是最好的方法,但如果你不能这样做,那么capture.output()
也可以:
junk <- capture.output(step.model <- MASS::stepAIC(mod1, direction = "both"))
如果您将stepAIC()
调用放在单独的 chunk中,我认为指定results="hide"
为 chunk 选项也可以。
推荐阅读
- angular - Angular Spectator 测试 ErrorHandler HttpErrorResponse
- c++ - 矢量调整大小行为复制和分配
- pandas - 切片熊猫数据框的列时保留索引
- angularjs - 如何将 mongoose bson 类型转换为 mongoose objectID
- python - 编码数据以进行插补,然后解码
- javascript - 删除 Vuetify 中的默认 v-input-file 图标
- angular - 为什么在使用单例类构建 Angular 包时出现错误?
- r - 可选参数与公式中的数据框冲突
- android - 注册后从数据库中检索数据的 JSON 错误
- jquery - 如何在 div 在响应式页面上保持 1:1.5 的比例时用图像填充 div