0

I ran a couple of simple OLS and used stargazer as below

stargazer(reg01, reg02, type="html")

However, the output in the RMD file simply lists the elements in rows not in a nice table Any idea why this is happening?

1

Thank you for your help!

vimuth
  • 5,064
  • 33
  • 79
  • 116
chunguc1004
  • 111
  • 1
  • It would be easier to help you if you provide [a minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) including a minimal working code or Rmd and a snippet of the data or some fake data to run the code. – stefan Mar 10 '23 at 06:29
  • Try to add the option`results='asis'` to your code chunk – L-- Mar 10 '23 at 10:15

1 Answers1

0

It looks like that you are trying to render to a PDF format (output: pdf_document), but give the table the type of a HTML file.

Here is a MWE with the correct YAML header for type = "html". For the next time, please add a complete MWE.

---
output: html_document
---

```{r results='asis'}
## OLS models
library(stargazer)
linear.1 <- lm(rating ~ complaints + privileges + learning + raises + critical,
data=attitude)
linear.2 <- lm(rating ~ complaints + privileges + learning, data=attitude)
## create an indicator dependent variable, and run a probit model
attitude$high.rating <- (attitude$rating > 70)
probit.model <- glm(high.rating ~ learning + critical + advance, data=attitude,
family = binomial(link = "probit"))
stargazer(linear.1, linear.2, probit.model, title="Results", type="html")
```
Julian
  • 6,586
  • 2
  • 9
  • 33