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

1

10

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")
```
Interviewer answered 17/10, 2014 at 19:42 Comment(4)
did you try {r results=asis}?Cwmbran
@hrbrmstr: tks a lot, it works! I will edit the question nowInterviewer
Only my first stargazer is output correctly dropbox.com/s/tryu6uci2dyc9aq/…Munford
@Cwmbran Don't forget to put answer as an answer below if it works?Angi
C
2

Remove the ' from 'asis'

ex: {r results=asis}

Crystalcrystalline answered 14/6, 2017 at 15:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.