Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove \begin{tabular} from Stargazer .tex output

Is there a simple way to automatically remove the

\begin{tabular}{@{\extracolsep{5pt}}lc}

and

\end{tabular}

lines at the beginning and end of a Stargazer LaTeX output?

Indeed, I just need the inside LaTeX code and removing those lines manually from the TeX file generated by stargazer is a complete loss of time...

like image 265
ℕʘʘḆḽḘ Avatar asked Oct 20 '22 05:10

ℕʘʘḆḽḘ


1 Answers

Each of the functions defined to create the LaTeX output in stargazer are defined within the (internal) wrapper function .stargazer.wrap. As such, it's not that easy to update the components automatically. You'll either have to make a copy of the package that you maintain locally, or edit the .stargazer.wrap function every time you load the package.

Here's how to do the latter, following the guidelines from How do I override a non-visible function in the package namespace? (managing your own copy would entail something similar):

  1. Load stargazer:

    > library(stargazer)
    
  2. Edit the .stargazer.wrap function inside the stargazer namespace/package:

    > fixInNamespace(".stargazer.wrap", pos="package:stargazer")
    
  3. Find and remove at least rows 4206-4207 from the .data.frame.table.header function:

    enter image description here

    These two lines are used to print the tabular header.

  4. Find and remove at least row 3385 in the .publish.table function:

    enter image description here

    This line prints \end{tabular} (plus a line break).

like image 190
Werner Avatar answered Oct 27 '22 21:10

Werner