0

有没有办法减少 htmlreg-table 的垂直大小?我有大约 10 个或更多 IV 的严重模型。所以 atm 我需要一整页来展示我的回归结果。我想通过报告 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)
) 

在此处输入图像描述

谢谢 :)

更新惊人、简单和优雅的解决方案是使用 stargazer-package。相当新:http ://www.r-statistics.com/2013/01/stargazer-package-for-beautiful-latex-tables-from-r-statistical-models-output/这个包可以导出精彩的latex-tables,比texreg好多了。

4

1 回答 1

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

您的原始结果在左侧,新的输出在右侧:

在此处输入图像描述在此处输入图像描述

如附加评论中所述,如果您对 LaTeX 输出而不是 HTML 感兴趣,请使用该texreg函数。htmlreg

编辑:HTML 输出现在看起来更好一些最新版本的texreg.

于 2016-08-03T01:30:16.150 回答