I'm trying to embed an output table, nicely formatted by the stargazer function, in a markdown document.
I tried embedding the stargazer() in an R code block in the Rmd document:
```{r}
library(stargazer)
stargazer(cor(attitude), type="html")
```
The code runs correctly, but it outputs the html code that in turn is not parsed by knitr, so the actual table html 'source' code is shown in the rendered document.
I'm aware of this similar question (here). I'm asking a separate question because most answers there indicate that stargazer does not support html output, which is no longer true. Html support was probably incorporated into stargazer after that tread (and I don´t have engouth rep to reopen or post comments there).
This seems related to a more simple problem of making knitr compile the html table source code.
EDIT: @hrbrmstr gave me the answer in the comment bellow, which is:
```{r results='asis'}
library(stargazer)
stargazer(cor(attitude), type="html")
```
{r results=asis}
? – Cwmbran