9
votes

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")
```
1
did you try {r results=asis}?hrbrmstr
@hrbrmstr: tks a lot, it works! I will edit the question nowLucasMation
Only my first stargazer is output correctly dropbox.com/s/tryu6uci2dyc9aq/…jacob
@hrbrmstr Don't forget to put answer as an answer below if it works?MrDaniel

1 Answers

2
votes

Remove the ' from 'asis'

ex: {r results=asis}