Skip to content

Instantly share code, notes, and snippets.

@jeffeaton
Created November 19, 2016 18:57
Show Gist options
  • Save jeffeaton/f804da95e109e2e7242642a4d927514f to your computer and use it in GitHub Desktop.
Save jeffeaton/f804da95e109e2e7242642a4d927514f to your computer and use it in GitHub Desktop.
read a stata dataset into R from a zip file
read_zipdta <- function(zfile){
tmp <- tempfile()
on.exit(unlink(tmp))
return(foreign::read.dta(unzip(zfile, grep(".dta", unzip(zfile, list=TRUE)$Name, TRUE, value=TRUE), exdir=tmp)))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment