Skip to content

Commit

Permalink
Creates cleanup function to solve the detritus issue noted by CRAN
Browse files Browse the repository at this point in the history
  • Loading branch information
hmeleiro committed May 30, 2024
1 parent 0e0c45a commit 39211e0
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ LazyData: true
Imports: dplyr (>= 1.0.0), stringr (>= 1.0.0), httr (>= 1.0.0)
Suggests:
ggplot2,
mapSpain,
mapSpain (>= 0.9.0),
patchwork,
purrr,
tidyr,
preferably,
preferably (>= 0.4.1),
knitr,
testthat (>= 3.0.0)
RoxygenNote: 7.2.3
Expand Down
2 changes: 2 additions & 0 deletions R/candidatos_nosenado.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,7 @@ candidatos_nosenado <- function(tipo, anno, mes) {
df$nacimiento <- NA
df$dni <- NA

cleanup(temp, tempd)

return(df)
}
13 changes: 13 additions & 0 deletions R/cleanup.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#' @title Cleans up the files and directories created during the process
#'
#' @param files The files to remove.
#' @param dirs The directories to remove.
#'
#' @return NULL
#'
#' @keywords internal
#'
cleanup <- function(files, dirs) {
file.remove(files)
unlink(dirs, recursive=TRUE)
}
3 changes: 3 additions & 0 deletions R/mesas.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,8 @@ mesas <- function(tipo_eleccion, anno, mes) {
)

df$municipio[df$codigo_municipio == "999"] <- "CERA"

cleanup(temp, tempd)

return(df)
}
2 changes: 2 additions & 0 deletions R/muni.R
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,7 @@ municipios <- function(tipo_eleccion, anno, mes, distritos = FALSE) {
df <- unique(df[df$codigo_distrito == 99, ])
}

cleanup(temp, tempd)

return(df)
}
2 changes: 2 additions & 0 deletions R/provincias.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,7 @@ provincias <- function(tipo_eleccion, anno, mes) {
desc("votos")
)

cleanup(temp, tempd)

return(df)
}
2 changes: 2 additions & 0 deletions R/senado_mesas.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,7 @@ senado_mesas <- function(anno, mes) {

df$nacimiento[df$nacimiento_anno == "0000"] <- NA

cleanup(temp, tempd)

return(df)
}
2 changes: 2 additions & 0 deletions R/senado_municipios.R
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,7 @@ senado_municipios <- function(anno, mes) {

df$nacimiento[df$nacimiento_anno == "0000"] <- NA

cleanup(temp, tempd)

return(df)
}

0 comments on commit 39211e0

Please sign in to comment.