tab_model has a file argument to direct html output to a file:
tab_model(fit, file = "xxx.html")
But this does not produce the desired output file when run in an Rmd script using the "Knit" button in RStudio.
If I run the same code either by pasting it into the console, or by Run Current Chunk in RStudio, it works and creates the output file.
RStudio 1.4.1717, sjPlot 2.8.9
Reproducible example:
---
title: "Reproducible example of tab_model file issue"
author: "Me"
date: "2/19/2022"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Run this chunk in console, does not produce correct output if knit.
```{r tabmodel}
library(sjPlot)
fit <- lm(mpg ~ cyl, data=mtcars)
tab_model(fit, file = "tabmodelOut.html")
# should produce html output in this named file.
#Does not do so if Rmd file is "knit" in RStudio
# Does correctly produce this output file if Run Current Chunk in RStudio
```