[英]stargazer output: how to omit one value of as.factor(variable)?
I have a model like this我有一个像这样的 model
model <-lm(outcome ~ var0 + var1 + as.factor(var2))
with var2
taking the values A
, B
, and C
. var2
取值A
、 B
和C
。 I create the output with stargazer
.我用
stargazer
创建了 output 。 I would like to omit var0
and as.factor(var2)A
from the output.我想从 output 中省略
var0
和as.factor(var2)A
。 I couldn't achieve this;我无法做到这一点; I tried:
我试过了:
stargazer(model, type = "html", out = "./output.html",
omit = c("var0", "var2")) # omits ALL var2 entries
stargazer(model, type = "html", out = "./output.html",
omit = c("var0", "as.factor(var2)B")) # omits no var2 entry in addition to the base category (A)
Can someone point me to the solution?有人可以指出我的解决方案吗? ( NB : this is not what this question asks, which wants to omit ALL entries of the variables.)
(注意:这不是这个问题所要求的,它想省略所有变量条目。)
The second example results in第二个示例导致
output.
output。 But I would like the entry marked in yellow to be omitted.
但我希望省略以黄色标记的条目。
This has something to do how stargazer
treats the omit
argument.这与
stargazer
如何处理omit
参数有关。 The documentation says that it expects a vector of regular expressions.文档说它需要一个正则表达式向量。 In a regular expression,
.
在正则表达式中,
.
, (
and )
are a special characters, so you have to escape them, in R
this is done with a double backslash \\
. ,
(
和)
是特殊字符,因此您必须转义它们,在R
中,这是通过双反斜杠\\
完成的。 So your argument becomes omit = c("var0", "as\\.factor\\(var2\\)B")
.所以你的论点变成
omit = c("var0", "as\\.factor\\(var2\\)B")
。
stargazer(model, type = "html", out = "./output.html",
omit = c("var0", "as\\.factor\\(var2\\)B"))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.