문제

When I perform a multinom reg. I have difficulties to get a nice summary with Rmd and and Knit HTLM (Rstudio). I would like to know how to get a nice summary as if I use the stargazer package with LaTeX... (cf. printscreen)

Summary output difficult to read ! enter image description here

Summary nice and easy to read with stargazer! enter image description here

도움이 되었습니까?

해결책

You can do this with xtable, which can write tables directly to HTML. Here is an example markdown document:

Title
========================================================    

My regression table.
```{r chunkTest, echo=FALSE, results='asis'}
library(xtable)
data(tli)
fm3 <- glm(disadvg ~ ethnicty*grade, data = tli, family = binomial())
fm3.table <- xtable(fm3)
# Coefficients
print(fm3.table, type = "html")
# Analysis of variance.
print(xtable(anova(fm3)), type = "html")
```

If you want the stars, there is a lovely package called texreg which can output with stars, and has some other nice features that xtable doesn't.

```{r chunkTest1, echo=FALSE, results='asis'}
library(texreg)
htmlreg(fm3,single.row=TRUE)
```

다른 팁

You could also set the option in stargazer to produce HTML code.

library(nnet) # For multinomial regression
library(stargazer)

df <- data.frame(Y = sample(c("A","B","C"), replace=T, size=1000), 
                 X = round(runif(1000)))
reg <- multinom(Y ~ X, data=df)
stargazer(reg, type='html')

<table style="text-align:center"><tr><td colspan="3" style="border-bottom: 1px solid black"></td></tr><tr><td style="text-align:left"></td><td colspan="2"><em>Dependent variable:</em></td></tr>
<tr><td></td><td colspan="2" style="border-bottom: 1px solid black"></td></tr>
<tr><td style="text-align:left"></td><td>B</td><td>C</td></tr>
<tr><td style="text-align:left"></td><td>(1)</td><td>(2)</td></tr>
<tr><td colspan="3" style="border-bottom: 1px solid black"></td></tr><tr><td style="text-align:left">X</td><td>-0.060</td><td>-0.142</td></tr>
<tr><td style="text-align:left"></td><td>(0.155)</td><td>(0.152)</td></tr>
<tr><td style="text-align:left"></td><td></td><td></td></tr>
<tr><td style="text-align:left">Constant</td><td>-0.148</td><td>-0.047</td></tr>
<tr><td style="text-align:left"></td><td>(0.111)</td><td>(0.108)</td></tr>
<tr><td style="text-align:left"></td><td></td><td></td></tr>
<tr><td colspan="3" style="border-bottom: 1px solid black"></td></tr><tr><td style="text-align:left">Akaike Inf. Crit.</td><td>2,198.764</td><td>2,198.764</td></tr>
<tr><td colspan="3" style="border-bottom: 1px solid black"></td></tr><tr><td style="text-align:left"><em>Note:</em></td><td colspan="2" style="text-align:right"><sup>*</sup>p<0.1; <sup>**</sup>p<0.05; <sup>***</sup>p<0.01</td></tr>
</table>

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top