How to show significance stars in R Markdown (rmarkdown) html output notes?
Asked Answered
K

1

5

I want to show regression outputs in HTML documents using R Markdown. I tried the texreg and stargazerpackages. My problem is now, that in the notes I can't bring the significance stars to life. Due to automatic generation it seems I can't escape them. I've been puzzling around with this and this but with no success. What am I missing? Thanks a lot!!

Here's some code:

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r data}
library(car)
lm1 <- lm(prestige ~ income + education, data=Duncan)
```
## with STARGAZER
```{r table1, results = "asis", message=FALSE}
library(stargazer)
stargazer(lm1, type="html", notes="stargazer html 1") # nothing
stargazer(lm1, type="html", notes="stargazer html 2", star.char = "\\*") # nothing, even gone in table
```
## with TEXREG
```{r table2, results = "asis", message=FALSE}
library(texreg)
htmlreg(lm1, custom.note="%stars. htmlreg") # nothing
htmlreg(lm1, custom.note="%stars. htmlreg", star.symbol = "\\*") # still nothing!
```

Note: Question was a former sub-question I have now splitted.

Knuckle answered 10/6, 2017 at 12:36 Comment(2)
Have you tried star.symbol='&#42;'?Buster
That works fantastic with texreg/htmlreg thanks!! In stargazer no changes, but even not when setting star.char = 'x'. My conclusion is to use the former for html and the latter for latex.Knuckle
B
5

Use the HTML entity for the asterisk:

star.symbol='&#42;'

See http://www.ascii.cl/htmlcodes.htm.

You could also add the "legend" manually:

stargazer(lm1, type="html", notes = "<em>&#42;p&lt;0.1;&#42;&#42;p&lt;0.05;&#42;&#42;&#42;p&lt;0.01</em>", notes.append = F)

enter image description here

Buster answered 10/6, 2017 at 14:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.