P-values significance not showed in stargazer html regression table
Asked Answered
M

3

1

I am having trouble with the Notes significance (asterisks) not appearing when using stargazer to format html tables. The result is ok when using latex.

Here is my source file "teste.Rmd"

---
title: "Untitled"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```


```{r data}
#some data
set.seed(123)
X = rnorm(500,10,3)
Y = 10+ 3*I(X^1.2) + rnorm(500)
# models
m1 = lm(Y~X)
m2 = lm(Y~X+I(X^2))

```

```{r res,warning=FALSE,message=FALSE,results='asis'}
library(stargazer)
stargazer(m1,m2,type = 'html',title = 'Models' )

```

The result is below

enter image description here

The same with latex produces this enter image description here

As you can see the asterisks in Notes are formatted correctly with latex but not with html option. How to get the same behavior with html?

Marlite answered 16/8, 2018 at 18:50 Comment(2)
Seems to be a bug, since option star.char='*' won't work. You can try texreg::htmlreg(list(m1, m2), star.symbol = '*')instead.Annatto
Works!! Thanks! Still stargazer offers better formatting optionsMarlite
M
2

Maybe it is a bug as @jaySf said in the comments to the original question. But based on @tmfmnk's answer and htmltools package I ended with a workaround. This is the updated relevant part of the source file.

```{r res,warning=FALSE,message=FALSE,results='hide'}
library(stargazer)
stargazer(m1,m2,type = 'html',title = 'Models', out = "table1.html")
```

```{r, echo=FALSE}
htmltools::includeHTML("table1.html")
```

Now I got the desired result enter image description here

Marlite answered 16/8, 2018 at 20:29 Comment(1)
Now in march 2024 using Quatro with html I have the same problem. This solution is still valid!!!Marlite
B
2

Try adding customized notes using notes and notes.append parameters as follows:

stargazer(m1,m2,type='html',notes="<span>&#42;&#42;&#42;</span>: p<0.01; <span>&#42;&#42;</span>: p<0.05; <span>&#42;</span>: p<0.1",notes.append=F)

I originally thought that using backslash to escape * will work, e.g. notes="\\*\\*\\*: p<0.01; \\*\\*: p<0.05; \\*: p<0.1". Unfortunately, it doesn't. I also tried to use the HTML code of *, i.e. &#42;, e.g. notes="&#42;&#42;&#42;: p<0.01; &#42;&#42;: p<0.05; &#42;: p<0.1". Still it doesn't work.

However, surrounding &#42; with an HTML tag works. It doesn't have to be <span></span>. I tried <b></b>, etc. and they worked.

Bacchanalia answered 25/7, 2019 at 21:38 Comment(0)
V
0

When exported through out it is working fine:

stargazer(m1,m2,type = 'html',
          title = 'Models',
          out = "/path/table.html")

enter image description here

Veronaveronese answered 16/8, 2018 at 19:1 Comment(2)
That's almost right. As a stand alone table.html works!!! But within the html document the problems persist.Marlite
Maybe try different style parameters.Veronaveronese

© 2022 - 2024 — McMap. All rights reserved.