From 7dc25da2c8cb01da5e13a36b8b518c3cca3f9241 Mon Sep 17 00:00:00 2001 From: Diego H Date: Wed, 20 Nov 2024 13:29:53 +0000 Subject: [PATCH] More robust column selection --- DESCRIPTION | 2 +- NEWS.md | 4 ++++ R/esp_get_prov.R | 9 ++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 1c7c1b9b..21554d62 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: mapSpain Title: Administrative Boundaries of Spain -Version: 0.9.2 +Version: 0.9.2.9000 Authors@R: person("Diego", "Hernangómez", , "diego.hernangomezherrero@gmail.com", role = c("aut", "cre", "cph"), comment = c(ORCID = "0000-0001-8457-4658", affiliation = "rOpenSpain")) diff --git a/NEWS.md b/NEWS.md index 71f4ac96..66f7a793 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# mapSpain (development version) + +- Fix a bug on `esp_get_prov_siane()` when selecting columns #115. + # mapSpain 0.9.2 - **SIANE 2024 Update**: Adapt functions to new databases. diff --git a/R/esp_get_prov.R b/R/esp_get_prov.R index a429f225..2957ab97 100644 --- a/R/esp_get_prov.R +++ b/R/esp_get_prov.R @@ -349,11 +349,18 @@ esp_get_prov_siane <- function(prov = NULL, year = Sys.Date(), epsg = "4258", colnames(esp_get_prov()) )) + # Review this error, can't fully reproduce + + namesend <- namesend[namesend %in% names(data_sf)] + data_sf <- data_sf[, namesend] if (isFALSE(rawcols)) { - data_sf <- data_sf[, colnames(esp_get_prov())] + nm <- colnames(esp_get_prov()) + nm <- nm[nm %in% colnames(data_sf)] + + data_sf <- data_sf[, nm] } return(data_sf)