texreg:如何在htmlreg-regression表中节省空间?

时间:2016-05-16 10:47:34

标签: r regression texreg

有没有办法减少htmlreg表的垂直大小?我有严重的模式,大约10或更多的静脉注射。所以我需要一整页来展示我的回归结果。我想通过在系数内联(旁边)报告SD或SE(括号内)来保存一些行。直接的方法是手动创建乳胶输出表。有一个简单的解决方案(更优雅的方式)?

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

谢谢:)

更新令人惊叹,简单而优雅的解决方案是使用stargazer-package。相当新:http://www.r-statistics.com/2013/01/stargazer-package-for-beautiful-latex-tables-from-r-statistical-models-output/这个包可以输出精美的乳胶表,比texreg好得多。

1 个答案:

答案 0 :(得分:0)

如果您仍希望使用texreg及其htmlreg函数完成此操作,请使用参数single.row = TRUE。以下是您的完整示例:

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)
)

您的原始结果位于左侧,右侧是新输出:

enter image description here enter image description here

下次请RTFM。另外,如果您对LaTeX输出而不是HTML感兴趣,请使用texreg函数而不是htmlreg,如您的其他评论中所述。