Receiving this Error "in if (is.na(s)) { : the condition has length > 1 " on R when using Stargazer for 6 multiple regressions

1.4k views Asked by At

I am currently doing some panel data regressions in R and I am trying to put multiple models side-by-side using stargazer

When I put 5 panel data models using stargazer I receive an output

reglogglobal2 <- plm(log1p(GDP_growth) ~ log1p(CO2emissions_per_capita) + log1p(inflation) + log1p(forest_area_sq_km) + log1p(nitrous_oxide_emissions) + log1p(methane_emissions), data = pdataglobal, model = "within")
stargazer(reglogglobal2, reglogglobal, reglog32, reglog33, reglog31,reg1og56,
          type = "text",
          header = FALSE,
          no.space = TRUE)

but when I put 6 I receive this error

enter image description here

Error in if (is.na(s)) { : the condition has length > 1

All my models and dataframes are defined . What does this error mean ? How can I solve it please ? Thank you

I was able to produce stargazer output with 6 lm models so I can confirm that stargazer works with 6 linear regressions. Not sure if it is because I am using panel data .

1

There are 1 answers

0
Aurore On

I don't know if that's still helpful for someone, but I had a similar problem and I found a quick solution here on Reddit: https://www.reddit.com/r/rstats/comments/ucmtdn/issue_with_stargazer_package_after_update_to_r_420/?rdt=36823

Apparently it's just a question of reducing the length of the model names. In any case it worked for me when I changed to shorter model names.