Search code examples
rlatexregressionstargazer

export regression table with stargazer: $ operator is invalid for atomic vectors


I am trying to export a regression table using stargazer. The regression output comes from glm and looks like:

Call:
glm(formula = formula, family = binomial(logit), data = data)

Deviance Residuals: 
Min       1Q   Median       3Q      Max  
-1.2913  -0.11888  -0.3239  -0.3216   2.6627  

Coefficients:
                        Estimate Std. Error z value Pr(>|z|)    
(Intercept)               -3.4839244  0.2439274 -14.283  < 2e-16 ***
data$var              0.00144  0.003666   0.021  0.2724    

unfortunately I have no control over the variable names of that regression. When I try to run stargazer to export the table in tex I get the error

$ operator is invalid for atomic vectors

What should I do? I tried to change the labels of the variables with stargazer but this does not work.

stargazer(glm_output,
      title            = "results",
      covariate.labels = c("newname"),
      dep.var.caption  = "caption",
      dep.var.labels   = "dep",
      rownames = FALSE)

Many thanks!!!


Solution

  • best solution was

    • tidy up the data with broom
    • use stargazer on the cleaned dataframe

    thanks!