Sometimes, you want to quickly check what the html output of xtable or similar function will look like in your markdown code, but you don't want to open up a new markdown document. Right from the console, you can create a temp html file, put the output in and view it in the viewer pane. This way you can quickly look at model output in that pane, as opposed to on the console.
require(xtable)
## Loading required package: xtable
hview = function(htmllines) {
htmlFile <- tempfile(fileext = ".html")
writeLines(htmllines, htmlFile)
rstudio::viewer(htmlFile)
}
data(tli)
fm2 <- lm(tlimth ~ sex * ethnicty, data = tli)
fm2.table <- xtable(fm2)
print(fm2.table, type = "html")
| Estimate | Std. Error | t value | Pr(> |t|) | |
|---|---|---|---|---|
| (Intercept) | 73.6364 | 4.2502 | 17.33 | 0.0000 |
| sexM | -1.6364 | 5.8842 | -0.28 | 0.7816 |
| ethnictyHISPANIC | -9.7614 | 6.5501 | -1.49 | 0.1395 |
| ethnictyOTHER | 15.8636 | 10.8360 | 1.46 | 0.1466 |
| ethnictyWHITE | 4.7970 | 4.9687 | 0.97 | 0.3368 |
| sexM:ethnictyHISPANIC | 10.6780 | 8.7190 | 1.22 | 0.2238 |
| sexM:ethnictyWHITE | 5.1230 | 7.0140 | 0.73 | 0.4670 |
hview(print(fm2.table, type = "html"))```
Keine Kommentare:
Kommentar veröffentlichen