When modelsummary produces a table for output type kableExtra, it wraps numbers in the notes in \num{}
tags, which show up in my PDF output. I want to disable this behaviour, or know how to properly handle this, so that the \num{}
tag doesn't show up in the output.
---
title: "My Document"
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE)
library(modelsummary)
library(kableExtra)
```
```{r table}
model <- lm(mpg ~ cyl, mtcars)
modelsummary(model,
output = "kableExtra",
escape = TRUE
stars = c("*" = .1, "**" = .05, "***" = .001)) %>%
column_spec(1, width = "5cm")
```
In this example, I use the stars argument which automatically produces a legend below the table explaining the stars. When this document is rendered, the note reads * p \num{< 0.1}, ** p \num{< 0.05}, *** p \num{< 0.001}
.
Theres a global option (discussed here) to disable wrapping numeric values, this however doesn't work in this case, as it only applies to values inside the table.
There's also the escape
argument in modelsummary which is TRUE
by default. Setting it to FALSE
did nothing for me.
Can this wrapping be disabled?
Possible workarounds:
- When introducing stars into the table by using glue syntax (e.g.
estimate = {estimate} {stars}
), the automatic note shouldn't be generated and I could then introduce my own custom note I supposed, but I'd rather have a less manual solution. - Using a different table package, but this is not always a viable option