我想要screenreg
中的多行自定义模型名称。我尝试了\n
lfit1 <- lm(Sepal.Length ~ Petal.Width, iris)
lfit2 <- lm(Sepal.Width ~ Petal.Width, iris)
library(texreg)
screenreg(mget(ls(pattern="lfit")),
custom.model.names=c("Length of sepal\nin cm",
"Width of sepal\nin cm"))
但这失败了:
========================================================
Length of sepal
in cm Width of sepal
in cm
--------------------------------------------------------
(Intercept) 4.78 *** 3.31 ***
(0.07) (0.06)
Petal.Width 0.89 *** -0.21 ***
(0.05) (0.04)
--------------------------------------------------------
R^2 0.67 0.13
Adj. R^2 0.67 0.13
Num. obs. 150 150
RMSE 0.48 0.41
========================================================
*** p < 0.001, ** p < 0.01, * p < 0.05
我希望输出头看起来像这样:
========================================================
Length of sepal Width of sepal
in cm in cm
--------------------------------------------------------
custom.model.names
很遗憾,不会接受矩阵。
因此,
我想在尝试的texreg
中实现相同的目标
texreg(mget(ls(pattern="lfit")),
custom.model.names=c("Length of sepal\\\\in cm",
"Width of sepal\\\\in cm"),
dcolumn=TRUE)
但这会完全失败,因为它会产生
& \multicolumn{1}{c}{Length of sepal\\in cm} & \multicolumn{1}{c}{Width of sepal\\in cm} \\
代替需要的
& \multicolumn{1}{c}{Length of sepal} & \multicolumn{1}{c}{Length of petal} \\
& \multicolumn{1}{c}{in cm} & \multicolumn{1}{c}{in cm} \\
想要的texreg
结果: