Reputation: 4200
I have a model like this
model <-lm(outcome ~ var0 + var1 + as.factor(var2))
with var2
taking the values A
, B
, and C
. I create the output with stargazer
. I would like to omit var0
and as.factor(var2)A
from the output. 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? (N.B.: this is not what this question asks, which wants to omit ALL entries of the variables.)
The second example results in output. But I would like the entry marked in yellow to be omitted.
Upvotes: 0
Views: 1257
Reputation: 10365
This has something to do how stargazer
treats the omit
argument. 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\\
. So your argument becomes omit = c("var0", "as\\.factor\\(var2\\)B")
.
stargazer(model, type = "html", out = "./output.html",
omit = c("var0", "as\\.factor\\(var2\\)B"))
Upvotes: 1