如果您不介意使用行标签,该texreg
软件包可以提供解决方案:
# your original code:
est <- matrix(1:10, nrow = 2)
colnames(est) <- c("a", "b", "c", "d", "e")
se <- matrix(seq(0.1, 1, by = 0.1), nrow = 2)
colnames(se) <- c("a", "b", "c", "d", "e")
# add row labels:
rownames(est) <- c("row 1", "row 2")
rownames(se) <- c("row 1", "row 2")
library("texreg")
# create a texreg object:
tr <- list()
for (j in 1:ncol(est)) {
tr[[j]] <- createTexreg(
coef.names = rownames(est),
coef = est[, j],
se = se[, j]
)
}
# for text output:
screenreg(tr, custom.model.names = colnames(est),
custom.note = "")
# for LaTeX output:
texreg(tr, custom.model.names = colnames(est),
custom.note = "")
# for HTML output:
htmlreg(tr, custom.model.names = colnames(est),
custom.note = "")
例如,文本输出如下所示:
=============================================
a b c d e
---------------------------------------------
row 1 1.00 3.00 5.00 7.00 9.00
(0.10) (0.30) (0.50) (0.70) (0.90)
row 2 2.00 4.00 6.00 8.00 10.00
(0.20) (0.40) (0.60) (0.80) (1.00)
=============================================
您也可以通过为 screenreg 函数 (inner.rule = ""
和outer.rule = ""
) 指定附加参数来省略顶部、底部和中间规则。
请注意,您应该已texreg
安装 (>= 1.29.7)。