[英]Remove the row with the model names from a texreg output in R
How do I remove the row with the model names from a texreg output?如何从 texreg 输出中删除带有模型名称的行?
custom.model.names = ""
or include.model.names = FALSE
custom.model.names = ""
或include.model.names = FALSE
don't do the trick.不要把戏。 I have only found how to change the names from default 'Model1', 'Model2', etc to custom 'M1', 'M2', etc我只找到了如何将名称从默认的“Model1”、“Model2”等更改为自定义的“M1”、“M2”等
Here is a reproducible example:这是一个可重现的例子:
# data sim
library(texreg)
set.seed(1)
x <- rnorm(1000)
z <- rnorm(1000)
y <- 5 + 2*x - z + rnorm(1000,0,40)/100
# regression
m1 <- lm(y~x)
summary(m1)
m2 <- lm(y~z)
summary(m2)
m3 <- lm(y~x+z)
summary(m3)
texreg(list(m1,m2,m2),
caption = "No Model Names or numbers, please!",
label = NULL,
model.names=c("M1","M2","M3"))
which generates the output:生成输出:
\begin{table}
\begin{center}
\begin{tabular}{l c c c}
\hline
& Model 1 & Model 2 & Model 3 \\
\hline
(Intercept) & $5.02^{***}$ & $4.98^{***}$ & $4.98^{***}$ \\
& $(0.04)$ & $(0.07)$ & $(0.07)$ \\
x & $2.01^{***}$ & & \\
& $(0.03)$ & & \\
z & & $-0.98^{***}$ & $-0.98^{***}$ \\
& & $(0.06)$ & $(0.06)$ \\
\hline
R$^2$ & $0.78$ & $0.19$ & $0.19$ \\
Adj. R$^2$ & $0.78$ & $0.18$ & $0.18$ \\
Num. obs. & $1000$ & $1000$ & $1000$ \\
\hline
\multicolumn{4}{l}{\scriptsize{$^{***}p<0.001$; $^{**}p<0.01$; $^{*}p<0.05$}}
\end{tabular}
\caption{No Model Names or numbers, please!}
\label{}
\end{center}
\end{table}
I would like to suppress/exclude the line in the output with我想抑制/排除输出中的行
& Model 1 & Model 2 & Model 3 \\
The solution is to edit the texregTable produced by texreg()
解决方案是编辑由texreg()
生成的 texregTable
in the above example,在上面的例子中,
mod <- texreg(list(m1,m2,m2),
caption = "No Model Names or numbers, please!")
alter post the texreg()
command the texregTable改变发布texreg()
命令 texregTable
mod <- gsub("\\hline\n & Model 1 & Model 2 & Model 3 \\\\\n", "", mod, fixed = T)
Now the output in the texregTable is现在 texregTable 中的输出是
> mod
\begin{table}
\begin{center}
\begin{tabular}{l c c c}
\hline
(Intercept) & $5.02^{***}$ & $4.98^{***}$ & $4.98^{***}$ \\
& $(0.04)$ & $(0.07)$ & $(0.07)$ \\
x & $2.01^{***}$ & & \\
& $(0.03)$ & & \\
z & & $-0.98^{***}$ & $-0.98^{***}$ \\
& & $(0.06)$ & $(0.06)$ \\
\hline
R$^2$ & $0.78$ & $0.19$ & $0.19$ \\
Adj. R$^2$ & $0.78$ & $0.18$ & $0.18$ \\
Num. obs. & $1000$ & $1000$ & $1000$ \\
\hline
\multicolumn{4}{l}{\scriptsize{$^{***}p<0.001$; $^{**}p<0.01$; $^{*}p<0.05$}}
\end{tabular}
\caption{No Model Names or numbers, please!}
\label{table:coefficients}
\end{center}
\end{table}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.