Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatización de la bajada de datos, etc. #2

Open
cjgb opened this issue Sep 27, 2019 · 0 comments
Open

Automatización de la bajada de datos, etc. #2

cjgb opened this issue Sep 27, 2019 · 0 comments

Comments

@cjgb
Copy link

cjgb commented Sep 27, 2019

Puedes bajar los datos automáticamente haciendo algo así como:

foo <- function(year){
  url <- gsub("XXXX", year, "ftp://www.ine.es/temas/varires/datos_XXXX.zip")
  
  download.file(url, destfile = "/tmp/tmp.zip")
  
  print(url)
   
  read_fwf("/tmp/tmp.zip",
           fwf_widths(c(1,2,3,3,2,4,3,2,3,2,4,2,3,1,1,1),
                      c("sexo", "provnac", "muninac", "edad", "mesnac", "anonac", "cnan", "provalta", "munialta", "mesvar", "anovar", "provbaja", "munibaja", "tamualta", "tamubaja", "tamunaci")))

}

tmp <- lapply(1988:1990, foo)

res <- do.call(rbind, tmp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant