On linux systems, wrapping a stargazer inside an invisible or suppressMessages works to suppress garbage that otherwise gets rendered. Unfortunately, this solution does not seem to work on Windows computers.
--- header-includes: - \usepackage{dcolumn} output: pdf_document ---

The reason is that (from the help page)
stargazer uses cat () to output LaTeX / HTML code or ASCII text for a table. To provide further processing for this output, stargazer also returns the same output discreetly as a character vector.
We use suppressMessages or invisible to ensure that only the first output (generated by cat) is displayed. The output of a character vector becomes garbage when rmarkdown tries to display it using print , not cat
source share