HTML Formatting for ‘mtable’ Results¶
Description¶
These functions formats ‘mtable’ objects into HTML format.
Usage¶
mtable_format_html(x,
interaction.sep = NULL,
toprule=2,midrule=1,bottomrule=2,
split.dec=TRUE,
style=mtable_format_stdstyle,
margin="2ex auto",
sig.notes.style=c(width="inherit"),
...
)
## S4 method for signature 'memisc_mtable'
format_html(x,
interaction.sep = NULL,
toprule=2,midrule=1,bottomrule=2,
split.dec=TRUE,
style=mtable_format_stdstyle,
margin="2ex auto",
sig.notes.style=c(width="inherit"),
...
)
Arguments¶
x
-
an object of class
mtable
toprule
-
integer; thickness in pixels of rule at the top of the table.
midrule
-
integer; thickness in pixels of rules within the table.
bottomrule
-
integer; thickness in pixels of rule at the bottom of the table.
interaction.sep
-
a character string that separates factors that are involved in an interaction effect or NULL. If NULL then a reasonable default is used (either a unicode character or an ampersand encoded HTML entity).
split.dec
-
logical; whether numbers should be centered at the decimal point by splitting the table cells.
style
-
string containing default the CSS styling.
margin
-
character string, determines the margin and thus the position of the HTML table.
sig.notes.style
-
a character vector with named elements, allows extra styling of the p-values notes at the bottom of the table.
...
-
further arguments, ignored.
Value¶
A character string with code suitable for inclusion into a HTML-file.
Examples¶
lm0 <- lm(sr ~ pop15 + pop75, data = LifeCycleSavings)
lm1 <- lm(sr ~ dpi + ddpi, data = LifeCycleSavings)
lm2 <- lm(sr ~ pop15 + pop75 + dpi + ddpi, data = LifeCycleSavings)
mtable123 <- mtable("Model 1"=lm0,"Model 2"=lm1,"Model 3"=lm2,
summary.stats=c("sigma","R-squared","F","p","N"))
(mtable123 <- relabel(mtable123,
"(Intercept)" = "Constant",
pop15 = "Percentage of population under 15",
pop75 = "Percentage of population over 75",
dpi = "Real per-capita disposable income",
ddpi = "Growth rate of real per-capita disp. income"
))
Calls:
Model 1: lm(formula = sr ~ pop15 + pop75, data = LifeCycleSavings)
Model 2: lm(formula = sr ~ dpi + ddpi, data = LifeCycleSavings)
Model 3: lm(formula = sr ~ pop15 + pop75 + dpi + ddpi, data = LifeCycleSavings)
================================================================================
Model 1 Model 2 Model 3
--------------------------------------------------------------------------------
Constant 30.628*** 6.360*** 28.566***
(7.409) (1.252) (7.355)
Percentage of population under 15 -0.471** -0.461**
(0.147) (0.145)
Percentage of population over 75 -1.934 -1.691
(1.041) (1.084)
Real per-capita disposable income 0.001 -0.000
(0.001) (0.001)
Growth rate of real per-capita disp. income 0.529* 0.410*
(0.210) (0.196)
--------------------------------------------------------------------------------
sigma 3.931 4.189 3.803
R-squared 0.262 0.162 0.338
F 8.332 4.528 5.756
p 0.001 0.016 0.001
N 50 50 50
================================================================================
Significance: *** = p < 0.001; ** = p < 0.01; * = p < 0.05
# Use HTML entity '−' for minus sign
options(html.use.ampersand=TRUE)
show_html(mtable123)
Model 1 | Model 2 | Model 3 | |||||||
Constant | 30 | . | 628*** | 6 | . | 360*** | 28 | . | 566*** |
(7 | . | 409) | (1 | . | 252) | (7 | . | 355) | |
Percentage of population under 15 | −0 | . | 471** | −0 | . | 461** | |||
(0 | . | 147) | (0 | . | 145) | ||||
Percentage of population over 75 | −1 | . | 934 | −1 | . | 691 | |||
(1 | . | 041) | (1 | . | 084) | ||||
Real per-capita disposable income | 0 | . | 001 | −0 | . | 000 | |||
(0 | . | 001) | (0 | . | 001) | ||||
Growth rate of real per-capita disp. income | 0 | . | 529* | 0 | . | 410* | |||
(0 | . | 210) | (0 | . | 196) | ||||
sigma | 3 | . | 931 | 4 | . | 189 | 3 | . | 803 |
R-squared | 0 | . | 262 | 0 | . | 162 | 0 | . | 338 |
F | 8 | . | 332 | 4 | . | 528 | 5 | . | 756 |
p | 0 | . | 001 | 0 | . | 016 | 0 | . | 001 |
N | 50 | 50 | 50 | ||||||
Significance: *** = p < 0.001; ** = p < 0.01; * = p < 0.05 |
show_html(mtable123[1:2],
sig.notes.style=c(width="30ex"))
Model 1 | Model 2 | |||||
Constant | 30 | . | 628*** | 6 | . | 360*** |
(7 | . | 409) | (1 | . | 252) | |
Percentage of population under 15 | −0 | . | 471** | |||
(0 | . | 147) | ||||
Percentage of population over 75 | −1 | . | 934 | |||
(1 | . | 041) | ||||
Real per-capita disposable income | 0 | . | 001 | |||
(0 | . | 001) | ||||
Growth rate of real per-capita disp. income | 0 | . | 529* | |||
(0 | . | 210) | ||||
sigma | 3 | . | 931 | 4 | . | 189 |
R-squared | 0 | . | 262 | 0 | . | 162 |
F | 8 | . | 332 | 4 | . | 528 |
p | 0 | . | 001 | 0 | . | 016 |
N | 50 | 50 | ||||
Significance: *** = p < 0.001; ** = p < 0.01; * = p < 0.05 |
# Use unicode for minus sign (default)
options(html.use.ampersand=FALSE)
show_html(mtable123)
Model 1 | Model 2 | Model 3 | |||||||
Constant | 30 | . | 628*** | 6 | . | 360*** | 28 | . | 566*** |
(7 | . | 409) | (1 | . | 252) | (7 | . | 355) | |
Percentage of population under 15 | 0 | . | 471** | 0 | . | 461** | |||
(0 | . | 147) | (0 | . | 145) | ||||
Percentage of population over 75 | 1 | . | 934 | 1 | . | 691 | |||
(1 | . | 041) | (1 | . | 084) | ||||
Real per-capita disposable income | 0 | . | 001 | 0 | . | 000 | |||
(0 | . | 001) | (0 | . | 001) | ||||
Growth rate of real per-capita disp. income | 0 | . | 529* | 0 | . | 410* | |||
(0 | . | 210) | (0 | . | 196) | ||||
sigma | 3 | . | 931 | 4 | . | 189 | 3 | . | 803 |
R-squared | 0 | . | 262 | 0 | . | 162 | 0 | . | 338 |
F | 8 | . | 332 | 4 | . | 528 | 5 | . | 756 |
p | 0 | . | 001 | 0 | . | 016 | 0 | . | 001 |
N | 50 | 50 | 50 | ||||||
Significance: *** = p < 0.001; ** = p < 0.01; * = p < 0.05 |