Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 886
jay.sf Avatar asked Jun 10 '17 12:06

jay.sf


People also ask

How do you show results in rmarkdown?

There are two ways to render an R Markdown document into its final output format. If you are using RStudio, then the “Knit” button (Ctrl+Shift+K) will render the document and display a preview of it. Note that both methods use the same mechanism; RStudio's “Knit” button calls rmarkdown::render() under the hood.

How do I write HTML in R Markdown?

To transform your markdown file into an HTML, PDF, or Word document, click the “Knit” icon that appears above your file in the scripts editor. A drop down menu will let you select the type of output that you want. When you click the button, rmarkdown will duplicate your text in the new file format.

What output formats can be generate from R Markdown?

There are two types of output formats in the rmarkdown package: documents, and presentations.

How do I create an index in R Markdown?

Authoring Books and Technical Documents with R Markdown An index entry can be created via the \index{} command in the book body, e.g., \index{GIT} .


1 Answers

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

like image 61
Martin Schmelzer Avatar answered Sep 21 '22 19:09

Martin Schmelzer