I recently posted a question asking how to create a long table using Stargazer in RMarkdown. I haven't found a solution but in looking did find another package with similar functionality and a "longtable" option, but it also isn't working in RMarkdown (or at least I'm not sure how to get it to work). Below is an example that more-or-less reproduces the problem. Note that the "tv_short" model works fine, but the "tv_long" does not compile.
I'm hoping a solution using this package might be more straightforward. If not, would anyone mind offering advice on how to ask a better question, or an alternative place to ask? The problem is a barrier to creating a reproducible document, so I greatly appreciate any help or feedback.
---
title: ""
header-includes:
- \usepackage{longtable}
output:
bookdown::pdf_document2:
toc: no
keep_tex: false
---
```{r, include=FALSE}
library(forcats) # for the gss_cat dataset
library(texreg) # to format the table
tv_short <- lm(tvhours ~ marital + age,
data = gss_cat)
tv_long <- lm(tvhours ~ marital + age + race + rincome + partyid + relig + denom,
data = gss_cat)
```
```{r, results='asis', echo = FALSE}
texreg(tv_long,
longtable = TRUE,
use.packages = FALSE)
```