Adding multicolumns to my texreg output
This may be late but still useful.
A new version of texreg
(1.36.28) just came out on GitHub (not on CRAN yet, May 22nd, 2020). It adds the option custom.header
to create groups of regressions.
Applied to your example, it creates:
library(texreg)
set.seed(01349)
DF <- data.frame(y = rnorm(100), x1A = rnorm(100), x2A = rnorm(100),
x1B = rnorm(100), x2B = rnorm(100))
regs <- lapply(paste0("x", 1:2, c("A", "A", "B", "B")), function(x)
lm(paste0("y ~ ", x), data = DF))
screenreg(
regs,
custom.header = list("A" = 1:2, "B" = 3:4),
custom.coef.names = c("Intercept", rep("x", 4)),
custom.model.names = c("1", "2", "1", "2"),
)
=============================================
A B
---------------- ----------------
1 2 1 2
---------------------------------------------
Intercept -0.13 -0.13 -0.11 -0.11
(0.12) (0.12) (0.12) (0.12)
x 0.02 0.07 0.13 -0.11
(0.13) (0.12) (0.12) (0.13)
---------------------------------------------
R^2 0.00 0.00 0.01 0.01
Adj. R^2 -0.01 -0.01 0.00 -0.00
Num. obs. 100 100 100 100
=============================================
*** p < 0.001; ** p < 0.01; * p < 0.05
I used screenreg()
to show the output more easily but it works with texreg()
too.