3

I would like to introduce a table with outputs of regression model generated via stargazer package into the RMarkdown document.

RMarkdown

The code pertaining to the RMarkdown document is given below:

---
title: "Text"
author: "Author"
date: "1 February 2016"
output: 
  pdf_document: 
    highlight: kate
    latex_engine: lualatex
    number_sections: yes
    toc: yes
---


```{r models, eval=TRUE, echo=FALSE}
# Data / Libs
data(mtcars)
lstModels <- list()
require(stargazer)

# Models
lstModels$mod1 <- lm(mpg ~ cyl + drat, data = mtcars)
lstModels$mod2 <- lm(gear ~ cyl + drat, data = mtcars)
```

Summary

```{r summaryModels, eval=TRUE, results="asis", echo=FALSE}
stargazer(lstModels,
          title = "Regression Results", type = "latex", 
          multicolumn = TRUE, no.space = TRUE,
          out.header = FALSE, header = FALSE)
```

Problem

The execution of the RMarkdown file fails:

output file: mod_example.knit.md

!LuaTeX error (file lmmi10): Font lmmi10 at 600 not found
 ==> Fatal error occurred, no output PDF file produced!

Sorry, but miktex-makemf did not succeed for the following reason:

  The lmmi source file could not be found.

The log file hopefully contains the information to get MiKTeX going again:

  C:/Users/me/AppData/Local/MiKTeX/2.9/miktex/log/miktex-makemf.log

You may want to visit the MiKTeX project page, if you need help.

Sorry, but miktex-makepk did not succeed for the following reason:

  PK font lmmi10 could not be created.

The log file hopefully contains the information to get MiKTeX going again:

  C:/Users/me/AppData/Local/MiKTeX/2.9/miktex/log/miktex-makepk.log

You may want to visit the MiKTeX project page, if you need help.

pandoc.exe: Error producing PDF from TeX source
Error: pandoc document conversion failed with error 43
In addition: Warning message:
running command '"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS mod_example.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output mod_example.pdf --table-of-contents --toc-depth 2 --template "C:\Users\Zdeb.Konrad\Documents\R\win-library\3.2\rmarkdown\rmd\latex\default.tex" --number-sections --highlight-style kate --latex-engine lualatex --variable graphics=yes --variable "geometry:margin=1in"' had status 43 
Execution halted

Notes

It appears that the stargazer generates the required code:

> stargazer(lstModels,
+           title = "Regression Results", type = "latex", 
+           multicolumn = TRUE, no.space = TRUE,
+           out.header = FALSE, header = FALSE)

\begin{table}[!htbp] \centering 
  \caption{Regression Results} 
  \label{} 
\begin{tabular}{@{\extracolsep{5pt}}lcc} 
\\[-1.8ex]\hline 
\hline \\[-1.8ex] 
 & \multicolumn{2}{c}{\textit{Dependent variable:}} \\ 
\cline{2-3} 
\\[-1.8ex] & mpg & gear \\ 
\\[-1.8ex] & (1) & (2)\\ 
\hline \\[-1.8ex] 
 cyl & $-$2.484$^{***}$ & $-$0.002 \\ 
  & (0.447) & (0.077) \\ 
  drat & 1.872 & 0.960$^{***}$ \\ 
  & (1.494) & (0.256) \\ 
  Constant & 28.725$^{***}$ & 0.251 \\ 
  & (7.592) & (1.303) \\ 
 \hline \\[-1.8ex] 
Observations & 32 & 32 \\ 
R$^{2}$ & 0.740 & 0.489 \\ 
Adjusted R$^{2}$ & 0.722 & 0.454 \\ 
Residual Std. Error (df = 29) & 3.176 & 0.545 \\ 
F Statistic (df = 2; 29) & 41.323$^{***}$ & 13.902$^{***}$ \\ 
\hline 
\hline \\[-1.8ex] 
\textit{Note:}  & \multicolumn{2}{r}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01} \\ 
\end{tabular}
\end{table} 

and following this discussion it should work with no problems. Is there anything that could be changed to make the latex output?

Community
  • 1
  • 1
Konrad
  • 17,740
  • 16
  • 106
  • 167
  • It compiles on my system without a problem. Try and see if the error remains after updating to a current MikTeX version. – Felix Feb 03 '16 at 12:31

0 Answers0