Convert LaTeX output from outreg to HTML markup
outreg2HTML.RdThis function is deprecated. Instead, please use outreg(type = "html")
Details
This will write the html on the screen, but if a filename argument is supplied, it will write a file. One can then open or insert the file into Libre Office or other popular "word processor" programs.
Author
Paul E. Johnson [email protected]
Examples
dat <- genCorrelatedData2(means = c(50,50,50,50,50,50),
sds = c(10,10,10,10,10,10), rho = 0.2, beta = rnorm(7), stde = 50)
#> [1] "The equation that was calculated was"
#> y = -0.3887704 + 0.170051163715846*x1 + 0.698106162851769*x2 + -1.31746411123807*x3 + 0.336734754149924*x4 + -0.566377227766106*x5 + 0.210669422412191*x6
#> + 0*x1*x1 + 0*x2*x1 + 0*x3*x1 + 0*x4*x1 + 0*x5*x1 + 0*x6*x1
#> + 0*x1*x2 + 0*x2*x2 + 0*x3*x2 + 0*x4*x2 + 0*x5*x2 + 0*x6*x2
#> + 0*x1*x3 + 0*x2*x3 + 0*x3*x3 + 0*x4*x3 + 0*x5*x3 + 0*x6*x3
#> + 0*x1*x4 + 0*x2*x4 + 0*x3*x4 + 0*x4*x4 + 0*x5*x4 + 0*x6*x4
#> + 0*x1*x5 + 0*x2*x5 + 0*x3*x5 + 0*x4*x5 + 0*x5*x5 + 0*x6*x5
#> + 0*x1*x6 + 0*x2*x6 + 0*x3*x6 + 0*x4*x6 + 0*x5*x6 + 0*x6*x6
#> + N(0,50) random error
m1 <- lm(y ~ x1 + x2 + x3 + x4 + x5 + x6 + x1*x2, data = dat)
summary(m1)
#>
#> Call:
#> lm(formula = y ~ x1 + x2 + x3 + x4 + x5 + x6 + x1 * x2, data = dat)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -94.776 -30.699 -4.195 27.076 141.137
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 31.429796 127.426572 0.247 0.8057
#> x1 0.212227 2.422428 0.088 0.9304
#> x2 1.090943 2.495897 0.437 0.6631
#> x3 -2.577079 0.524115 -4.917 3.82e-06 ***
#> x4 0.225474 0.495261 0.455 0.6500
#> x5 -0.752895 0.490101 -1.536 0.1279
#> x6 1.045539 0.499499 2.093 0.0391 *
#> x1:x2 -0.002072 0.046938 -0.044 0.9649
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Residual standard error: 48.72 on 92 degrees of freedom
#> Multiple R-squared: 0.2647, Adjusted R-squared: 0.2088
#> F-statistic: 4.732 on 7 and 92 DF, p-value: 0.0001424
#>
m1out <- outreg(list("Great Regression" = m1), alpha = c(0.05, 0.01, 0.001),
request = c("fstatistic" = "F"), runFuns = c(AIC = "AIC"),
float = TRUE)
#> \begin{table}
#> \caption{A Regression}\label{regrlabl}
#> \begin{tabular}{@{}l*{2}{l}@{}}
#> \hline
#> &\multicolumn{1}{l}{Great Regression }\tabularnewline
#> &\multicolumn{1}{l}{Estimate}\tabularnewline
#> &\multicolumn{1}{l}{(S.E.)}\tabularnewline
#> \hline
#> \hline
#> (Intercept) & 31.430 \tabularnewline
#> &(127.427)\tabularnewline
#> x1 & 0.212 \tabularnewline
#> &( 2.422)\tabularnewline
#> x2 & 1.091 \tabularnewline
#> &( 2.496)\tabularnewline
#> x3 & -2.577*** \tabularnewline
#> &( 0.524)\tabularnewline
#> x4 & 0.225 \tabularnewline
#> &( 0.495)\tabularnewline
#> x5 & -0.753 \tabularnewline
#> &( 0.490)\tabularnewline
#> x6 & 1.046* \tabularnewline
#> &( 0.499)\tabularnewline
#> x1:x2 & -0.002 \tabularnewline
#> &( 0.047)\tabularnewline
#> \hline
#> N&\multicolumn{1}{l}{100} \tabularnewline
#> RMSE&48.724\tabularnewline
#> $R^2$&0.265\tabularnewline
#> adj $R^2$&0.209\tabularnewline
#> F($df_{num}$,$df_{denom}$)&\multicolumn{1}{c}{4.73(7,92)***}\tabularnewline
#> AIC&\multicolumn{1}{c}{1070.68}\tabularnewline
#> \hline
#> \hline
#>
#> \multicolumn{2}{l}{ ${* p}\le 0.05$${*\!\!* p}\le 0.01$${*\!\!*\!\!* p}\le 0.001$}\tabularnewline
#> \end{tabular}
#> \end{table}
#>
##html markup will appear on screen
outreg2HTML(m1out)
#> <tr><td>\begin{table
#> \caption{A Regression\label{regrlabl
#> <table>
#> <tr><td> </td><td colspan = '1'> Great Regression \tabularnewline
#> <tr><td></td><td colspan = '1'> Estimate\tabularnewline
#> <tr><td></td><td colspan = '1'> (S.E.)\tabularnewline
#> <tr><td> (Intercept) </td><td> 31.430 \tabularnewline
#> <tr><td></td><td>(127.427)\tabularnewline
#> <tr><td> x1 </td><td> 0.212 \tabularnewline
#> <tr><td></td><td>( 2.422)\tabularnewline
#> <tr><td> x2 </td><td> 1.091 \tabularnewline
#> <tr><td></td><td>( 2.496)\tabularnewline
#> <tr><td> x3 </td><td> -2.577*** \tabularnewline
#> <tr><td></td><td>( 0.524)\tabularnewline
#> <tr><td> x4 </td><td> 0.225 \tabularnewline
#> <tr><td></td><td>( 0.495)\tabularnewline
#> <tr><td> x5 </td><td> -0.753 \tabularnewline
#> <tr><td></td><td>( 0.490)\tabularnewline
#> <tr><td> x6 </td><td> 1.046* \tabularnewline
#> <tr><td></td><td>( 0.499)\tabularnewline
#> <tr><td> x1:x2 </td><td> -0.002 \tabularnewline
#> <tr><td></td><td>( 0.047)\tabularnewline
#> <tr><td>N</td><td colspan = '1'> 100 \tabularnewline
#> <tr><td>RMSE</td><td>48.724\tabularnewline
#> <tr><td>R<sup>2</sup></td><td>0.265\tabularnewline
#> <tr><td>adj R<sup>2</sup></td><td>0.209\tabularnewline
#> <tr><td>F( df_{num , df_{denom )</td><td colspan = '1'> 4.73(7,92)***\tabularnewline
#> <tr><td>AIC</td><td colspan = '1'> 1070.68\tabularnewline
#> <tr><td></tr></td>
#> <tr><td colspan = '3'>* p≤ 0.05 *\!\!* p≤ 0.01 *\!\!*\!\!* p≤ 0.001 \tabularnewline
#> </table>
#> <tr><td>\end{table
#>
## outreg2HTML(m1out, filename = "funky.html")
## I'm not running that for you because you
## need to be in the intended working directory
m2 <- lm(y ~ x1 + x2, data = dat)
m2out <- outreg(list("Great Regression" = m1, "Small Regression" = m2),
alpha = c(0.05, 0.01, 0.01),
request = c("fstatistic" = "F"), runFuns = c(BIC = "BIC"))
#> \begin{tabular}{@{}l*{3}{l}@{}}
#> \hline
#> &\multicolumn{1}{l}{Great Regression } &\multicolumn{1}{l}{Small Regression }\tabularnewline
#> &\multicolumn{1}{l}{Estimate}&\multicolumn{1}{l}{Estimate}\tabularnewline
#> &\multicolumn{1}{l}{(S.E.)}&\multicolumn{1}{l}{(S.E.)}\tabularnewline
#> \hline
#> \hline
#> (Intercept) & 31.430 & -27.148 \tabularnewline
#> &(127.427)&(33.254)\tabularnewline
#> x1 & 0.212 & -0.313 \tabularnewline
#> &( 2.422)&( 0.568)\tabularnewline
#> x2 & 1.091 & 0.611 \tabularnewline
#> &( 2.496)&( 0.537)\tabularnewline
#> x3 & -2.577*** &\multicolumn{1}{l}{\_ }\tabularnewline
#> &( 0.524) &\tabularnewline
#> x4 & 0.225 &\multicolumn{1}{l}{\_ }\tabularnewline
#> &( 0.495) &\tabularnewline
#> x5 & -0.753 &\multicolumn{1}{l}{\_ }\tabularnewline
#> &( 0.490) &\tabularnewline
#> x6 & 1.046* &\multicolumn{1}{l}{\_ }\tabularnewline
#> &( 0.499) &\tabularnewline
#> x1:x2 & -0.002 &\multicolumn{1}{l}{\_ }\tabularnewline
#> &( 0.047) &\tabularnewline
#> \hline
#> N&\multicolumn{1}{l}{100}&\multicolumn{1}{l}{100} \tabularnewline
#> RMSE&48.724 &54.963\tabularnewline
#> $R^2$&0.265 &0.014\tabularnewline
#> adj $R^2$&0.209 &-0.007\tabularnewline
#> F($df_{num}$,$df_{denom}$)&\multicolumn{1}{c}{4.73(7,92)***} &\multicolumn{1}{c}{0.667(2,97)}\tabularnewline
#> BIC&\multicolumn{1}{c}{1094.13} &\multicolumn{1}{c}{1100.49}\tabularnewline
#> \hline
#> \hline
#>
#> \multicolumn{3}{l}{ ${* p}\le 0.05$${*\!\!* p}\le 0.01$${*\!\!*\!\!* p}\le 0.01$}\tabularnewline
#> \end{tabular}
outreg2HTML(m2out)
#> <table>
#> <tr><td> </td><td colspan = '1'> Great Regression </td><td colspan = '1'> Small Regression \tabularnewline
#> <tr><td></td><td colspan = '1'> Estimate</td><td colspan = '1'> Estimate\tabularnewline
#> <tr><td></td><td colspan = '1'> (S.E.)</td><td colspan = '1'> (S.E.)\tabularnewline
#> <tr><td> (Intercept) </td><td> 31.430 </td><td> -27.148 \tabularnewline
#> <tr><td></td><td>(127.427)</td><td>(33.254)\tabularnewline
#> <tr><td> x1 </td><td> 0.212 </td><td> -0.313 \tabularnewline
#> <tr><td></td><td>( 2.422)</td><td>( 0.568)\tabularnewline
#> <tr><td> x2 </td><td> 1.091 </td><td> 0.611 \tabularnewline
#> <tr><td></td><td>( 2.496)</td><td>( 0.537)\tabularnewline
#> <tr><td> x3 </td><td> -2.577*** </td><td colspan = '1'> \_ \tabularnewline
#> <tr><td></td><td>( 0.524) </td><td>\tabularnewline
#> <tr><td> x4 </td><td> 0.225 </td><td colspan = '1'> \_ \tabularnewline
#> <tr><td></td><td>( 0.495) </td><td>\tabularnewline
#> <tr><td> x5 </td><td> -0.753 </td><td colspan = '1'> \_ \tabularnewline
#> <tr><td></td><td>( 0.490) </td><td>\tabularnewline
#> <tr><td> x6 </td><td> 1.046* </td><td colspan = '1'> \_ \tabularnewline
#> <tr><td></td><td>( 0.499) </td><td>\tabularnewline
#> <tr><td> x1:x2 </td><td> -0.002 </td><td colspan = '1'> \_ \tabularnewline
#> <tr><td></td><td>( 0.047) </td><td>\tabularnewline
#> <tr><td>N</td><td colspan = '1'> 100</td><td colspan = '1'> 100 \tabularnewline
#> <tr><td>RMSE</td><td>48.724 </td><td>54.963\tabularnewline
#> <tr><td>R<sup>2</sup></td><td>0.265 </td><td>0.014\tabularnewline
#> <tr><td>adj R<sup>2</sup></td><td>0.209 </td><td>-0.007\tabularnewline
#> <tr><td>F( df_{num , df_{denom )</td><td colspan = '1'> 4.73(7,92)*** </td><td colspan = '1'> 0.667(2,97)\tabularnewline
#> <tr><td>BIC</td><td colspan = '1'> 1094.13 </td><td colspan = '1'> 1100.49\tabularnewline
#> <tr><td></tr></td>
#> <tr><td colspan = '3'>* p≤ 0.05 *\!\!* p≤ 0.01 *\!\!*\!\!* p≤ 0.01 \tabularnewline
#> </table>
## Run this for yourself, it will create the output file funky2.html
## outreg2HTML(m2out, filename = "funky2.html")
## Please inspect the file "funky2.html