1

Is there a way to reduce the vertical size of a htmlreg-table? I have severeal modells with about 10 or more IV. So atm I need an entire page to present my regressions results. I would like to save some lines by reporting SD or SE (in parenthesis) inline (next to) the coefficients. Straightforward way is creating output-tables in latex by hand. Is there an easy solution (more elegant way)?

library(texreg)

alligator = data.frame(
  lnLength = c(3.87, 3.61, 4.33, 3.43, 3.81, 3.83, 3.46, 3.76,
               3.50, 3.58, 4.19, 3.78, 3.71, 3.73, 3.78),
  lnWeight = c(4.87, 3.93, 6.46, 3.33, 4.38, 4.70, 3.50, 4.50,
               3.58, 3.64, 5.90, 4.43, 4.38, 4.42, 4.25)
)

alli.mod = lm(lnWeight ~ lnLength, data = alligator)

htmlreg(list(alli.mod),
        file="MWE_regression.html", 
        caption="MWE Regression", 
        caption.above = TRUE,
        include.rs=TRUE, 
        include.adjrs = FALSE,
        digits=3,
        stars=c(0.01, 0.05, 0.1)
) 

enter image description here

Thanks :)

Update The amazing, simple and elegant solution is using the stargazer-package. Quite new: http://www.r-statistics.com/2013/01/stargazer-package-for-beautiful-latex-tables-from-r-statistical-models-output/ this package can export wonderful latex-tables, much much better than the texreg.

Mac
  • 183
  • 1
  • 13

1 Answers1

0

If you'd still like to accomplish this with texreg and its htmlreg function, just use the argument single.row = TRUE. Here is your full example:

library(texreg)

alligator = data.frame(
  lnLength = c(3.87, 3.61, 4.33, 3.43, 3.81, 3.83, 3.46, 3.76,
               3.50, 3.58, 4.19, 3.78, 3.71, 3.73, 3.78),
  lnWeight = c(4.87, 3.93, 6.46, 3.33, 4.38, 4.70, 3.50, 4.50,
               3.58, 3.64, 5.90, 4.43, 4.38, 4.42, 4.25)
)

alli.mod = lm(lnWeight ~ lnLength, data = alligator)

htmlreg(list(alli.mod),
        single.row = TRUE, 
        file="MWE_regression.html", 
        caption="MWE Regression", 
        caption.above = TRUE,
        include.rs=TRUE, 
        include.adjrs = FALSE,
        digits=3,
        stars=c(0.01, 0.05, 0.1)
)

Your original result is on the left, the new output on the right:

enter image description hereenter image description here

Use the texreg function instead of htmlreg if you are interested in LaTeX output rather than HTML, as mentioned in your additional comment.

Edit: The HTML output now looks a bit nicer with more recent versions of texreg.

Philip Leifeld
  • 2,253
  • 15
  • 24