stargazer omit.labels的潜在错误

在stargazer软件包的5.2版中似乎存在一个错误,其中omit.label功能根据所包含模型的顺序不能始终如一地工作:

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"))

有没有人知道一个解决方法?

最佳答案 我只是使用add.lines属性为每列手动指定了虚拟对象.对于你的例子:

stargazer(fit.1, fit.2, omit = c("state"),
    add.lines = list(
        c("States", "No", "Yes")
    )
)
点赞