Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making nicely formatted tables in Markdown: knitr not compiling stargazer>html table

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")
```
like image 803
LucasMation Avatar asked Oct 17 '14 19:10

LucasMation


1 Answers

Remove the ' from 'asis'

ex: {r results=asis}

like image 136
Mamunur Rashid Avatar answered Oct 22 '22 20:10

Mamunur Rashid