I try publishing a table in a pdf format using the gtsummary package in Rmarkdown. The code in Rmarkdown is as below:
---
title: "test"
author: "Tengku Hanis"
date: "`r Sys.Date()`"
output: pdf_document
---
```{r pressure, echo=FALSE}
mod <- lm(mpg ~ ., data = mtcars)
summary(mod)
```
```{r message=FALSE, error=FALSE, warning=FALSE}
library(tidyverse)
library(gtsummary)
```
```{r}
tbl_regression(mod, intercept = TRUE) %>% as_gt()
```
When I try to knit, I get the following error:
! Undefined control sequence.
<argument> ...al \expandafter \let \cmrsideswitch
\@tempa \fi \fi
l.164 (Intercept)
& 12 & -27, 51 & 0.5 \\
Error: LaTeX failed to compile test.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See test.log for more info.
Execution halted
Is there any way to publish a table using tbl_regression()
in pdf format while setting the intercept = TRUE
? I think this argument somehow in conflict with as_gt()
?