Votaciones

¿Siguen votando igual los diputados?

Hace seis años escribí esto. Hoy actualizo aquella entrada para crear Y, por supuesto, el código (que he tenido que reescribir en gran medida): library(xml2) library(reshape2) library(plyr) # descarga y manipulación de datos dia_votacion <- function(n.votacion){ dir.create("tmp") url <- paste("https://app.congreso.es/votacionesWeb/OpenData?sesion=", n.votacion, "&completa;=1&legislatura;=12", sep = "") download.file( url, destfile = "./tmp/votos.zip") try(unzip("./tmp/votos.zip", exdir = "./tmp"), TRUE) ficheros <- dir("./tmp", pattern = ".*xml", full.names = T) if (length(ficheros) == 0) return(NULL) res <- lapply(ficheros, function(fichero){ print(fichero) datos <- as_list(read_xml(fichero)) sesion <- datos$Resultado$Informacion$Sesion numero <- datos$Resultado$Informacion$NumeroVotacion try(datos <- ldply(datos$Resultado$Votaciones, unlist), TRUE) if (class(datos) == "try-error") return(NULL) if (class(datos) !