如何在R Markdown(rmarkdown)的HTML输出注释中显示显著性星号?

5
我希望使用R Markdown在HTML文档中展示回归输出。我尝试了texregstargazer包。问题是,在注释中,我无法将显着性星号显示出来。由于自动生成,似乎我无法逃脱它们。我一直在研究这个这个,但没有成功。我错过了什么?非常感谢!

以下是一些代码:

```{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!
```

注意: 这个问题曾经是一个子问题,现在已分开处理。


1
你尝试过 star.symbol='&#42;' 吗? - Martin Schmelzer
这个与 texreg/htmlreg 配合使用效果非常好,谢谢!在 stargazer 中没有变化,即使设置了 star.char = 'x' 也是如此。我的结论是在 html 中使用前者,在 latex 中使用后者。 - jay.sf
1个回答

5
请使用星号的HTML实体表示:
star.symbol='&#42;'

请查看 http://www.ascii.cl/htmlcodes.htm,此链接涉及 IT 技术相关内容。您也可以手动添加“说明”。
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


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接