There appears to be a bug in version 5.2 of the stargazer
package, where the omit.label
functionality does not work consistently depending on the order of the included models:
library(stargazer)
library(ggplot2)
as.data.frame(data("midwest"))
fit.1 <- lm(poptotal ~ popadults, data = midwest)
fit.2 <- lm(poptotal ~ popadults + state, data = midwest)
# Works, column listed as "Yes":
stargazer(fit.2, omit = c("state"), omit.labels = c("States"))
# Does not work, both columns listed as "No":
stargazer(fit.1, fit.2, omit = c("state"), omit.labels = c("States"))
# Works, first column "Yes", second "No":
stargazer(fit.2, fit.1, omit = c("state"), omit.labels = c("States"))
Does anyone know of a workaround?
I just manually specified dummies for each column using the add.lines
property. For your example:
stargazer(fit.1, fit.2, omit = c("state"),
add.lines = list(
c("States", "No", "Yes")
)
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With