rr-markdowngtsummarynnet

Suppress weights information from nnet package in rmarkdown


Is it possible to suppress the weights information from the nnet package in rmarkdown? If I set include = FALSE, everything will be hidden. message = FALSE does not appear to work.

---
title: "Crimes"
date: "19/11/2021"
output: word_document
---

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

set.seed(20211119)

# dummy data
crime <-
  data.frame(
    city = sample(c("SF", "AR", "NYC", "MN"), 13000, replace = TRUE),
    year = sample(as.factor(c(1990, 2000, 1999, 1989)), 13000, replace = TRUE)
  )

```


```{r}
tbl <-
  nnet::multinom(city ~ year, data = crime) %>%
  tbl_regression(exponentiate = TRUE)
tbl

```

Solution

  • Do you want this output?

    ```{r, message = FALSE, echo = FALSE, include = FALSE}
    tbl <-
      nnet::multinom(city ~ year, data = crime) %>%
      tbl_regression(exponentiate = TRUE)
    ```
    
    ```{r}
    tbl
    ```
    

    enter image description here