Skip to content

Instantly share code, notes, and snippets.

@alexeyknorre
Created May 31, 2022 04:50
Show Gist options
  • Star 26 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save alexeyknorre/b0780836f4cec04d41a863a683f91b53 to your computer and use it in GitHub Desktop.
Save alexeyknorre/b0780836f4cec04d41a863a683f91b53 to your computer and use it in GitHub Desktop.
Quick fix for stargazer <= 5.2.3 is.na() issue with long model names in R >= 4.2
## Quick fix for stargazer <= 5.2.3 is.na() issue with long model names in R >= 4.2
# Unload stargazer if loaded
detach("package:stargazer",unload=T)
# Delete it
remove.packages("stargazer")
# Download the source
download.file("https://cran.r-project.org/src/contrib/stargazer_5.2.3.tar.gz", destfile = "stargazer_5.2.3.tar.gz")
# Unpack
untar("stargazer_5.2.3.tar.gz")
# Read the sourcefile with .inside.bracket fun
stargazer_src <- readLines("stargazer/R/stargazer-internal.R")
# Move the length check 5 lines up so it precedes is.na(.)
stargazer_src[1990] <- stargazer_src[1995]
stargazer_src[1995] <- ""
# Save back
writeLines(stargazer_src, con="stargazer/R/stargazer-internal.R")
# Compile and install the patched package
install.packages("stargazer", repos = NULL, type="source")
@Nick-Pupkin
Copy link

Thanks a lot for this solution! You are a life saver)

@IZE85
Copy link

IZE85 commented Mar 18, 2023

thank you, alexey!

@hakuna-max
Copy link

Thank you, alexey. You've done me a big favor.

@jaschwer
Copy link

I still get an error if I include more than 4 regression results in stargazer.

@bryanpallero
Copy link

Thank you, Alexey. You save me!

@guanghwang
Copy link

Thank you, Alexey !

@AlejandroRomeroG
Copy link

Thank you so much! The tables in my thesis would not be possible without your solution. I was able to put the results of 8 Probits into a table without problems.

@Ocalak
Copy link

Ocalak commented Aug 7, 2023

Thanks a lot!!!

@XiaoruiZhu
Copy link

Great fix.

@ToniErtl
Copy link

Great fix, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment