You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was attempting to create a long regression table with Stargazer, but ran into problems and was delighted to find the texreg package and to see it has a longtable option. When I attempted to create the table, however, I received an error message. I posted two related questions on the RStudio community forum (one regarding Stargazer and one regarding the question I'm posting here) and got over a hundred views between the two posts, but no responses. I hope I'm not violating any community norms by re-posing the question here, but it seems like going to the source might be the best approach here.
Below is an example that reproduces the problem. This example doesn't give me the exact error message I get when using my own data, but it's close so I'm hoping a solution to one might result in a solution to the other. Note that the "tv_short" model works fine, but the "tv_long" model doesn't work when calling texreg directly or when pasting the results of the LaTex output into the .Rms.
As an aside, the exact error message I'm getting with my own data (not the gss_cat data) is:
! Misplaced \noalign.
\hline ->\noalign
{\ifnum 0=`}\fi \let \hskip \vskip \let \vrule \hrule \let...
l.166 \hline
Error: LaTeX failed to compile render_preview.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See render_preview.log for more info.
Execution halted
The error message from knitting the .Rmd below is:
! Extra }, or forgotten $.
<template> \unskip \hfil }
\hskip \tabcolsep \endtemplate
l.115 rincome$25000 or more &
$-0.58^{*}$ \\
Error: LaTeX failed to compile longtable_texreg.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See longtable_texreg.log for more info.
Execution halted
Please let me know if I can clarify anything. I very much appreciate your time and attention.
Hi, and thanks again for your time and attnetion. I did end up getting a reply on the RStudio forum that solved the problem (for both datasets, despite the different error messages). Apparently the $ in the income variable is a special character in LaTex and needs to be removed from the variable in advance of running the model so that it doesn't get passed to texreg. The solution was posted here: https://community.rstudio.com/t/how-to-use-texreg-for-a-long-table-in-rmarkdown/99509/3
Essentially, cderv at RStudio suggested the following to remove the $ before running the model:
Hi,
I was attempting to create a long regression table with Stargazer, but ran into problems and was delighted to find the texreg package and to see it has a longtable option. When I attempted to create the table, however, I received an error message. I posted two related questions on the RStudio community forum (one regarding Stargazer and one regarding the question I'm posting here) and got over a hundred views between the two posts, but no responses. I hope I'm not violating any community norms by re-posing the question here, but it seems like going to the source might be the best approach here.
Below is an example that reproduces the problem. This example doesn't give me the exact error message I get when using my own data, but it's close so I'm hoping a solution to one might result in a solution to the other. Note that the "tv_short" model works fine, but the "tv_long" model doesn't work when calling texreg directly or when pasting the results of the LaTex output into the .Rms.
As an aside, the exact error message I'm getting with my own data (not the gss_cat data) is:
The error message from knitting the .Rmd below is:
Please let me know if I can clarify anything. I very much appreciate your time and attention.
The text was updated successfully, but these errors were encountered: