对 as.factor(var) 使用 stargazer(..., order = c(...))

Use stargazer(..., order = c(...)) for as.factor(var)

我有一个这样的回归模型:

Call:
glm(formula = DV ~ as.factor(IV), family = "binomial", data = df)

[...]
Coefficients:
                                       Estimate Std. Error z value Pr(>|z|)    
(Intercept)                          -2.104e+01  3.956e+03  -0.005   0.9958    
as.factor(IV)AAA                      2.626e-01  2.962e-01   0.887   0.3752    
as.factor(IV)BBB                      4.150e-01  3.176e-01   1.307   0.1913    
as.factor(IV)CCC                      8.060e-01  3.551e-01   2.270   0.0232 *  
as.factor(IV)DDD                      2.640e+00  3.210e-01   8.222  < 2e-16 ***

使用 stargazer,我想重新排序输出。我想将条目的 顺序 更改为 "as.factor(IV)BBB", "as.factor(IV)AAA", "as.factor(IV)DDD", "as.factor(IV)CCC" 并将它们重命名为 c("BBB", "AAA", "DDD", "CCC");我试过这个和类似的电话:

stargazer(model, type = "html", out = "./out/test.html", 
      title = "Title", order = c("as.factor(IV)BBB", "as.factor(IV)AAA",
                                 "as.factor(IV)DDD", "as.factor(IV)CCC")

不幸的是,我既无法让它工作,也无法在文档中找到帮助。

您可以使用数字索引更改顺序,然后使用 covariate.labels

重命名
stargazer(model, type = "html", out = "./out/test.html", 
      title = "Title", order = c(2, 1, 4, 3), covariate.labels = c("BBB", "AAA", "DDD", "CCC"))