install.packages("spanishoddata",
  repos = c("https://e-kotov.r-universe.dev", "https://cloud.r-project.org"))
zones <- spanishoddata::spod_get_zones("gau", ver = 2)Missing column names in Large Urban Areas population CSV
tabular data
    metadata
    importance: low
  Status: ✅ resolved
Importance: 1 - low
Summary: CSV file with Large Urban Areas population data is missing column names.
Expected Results: The dataset should have ID and population columns.
Resolution: resolved with https://github.com/Robinlovelace/spanishoddata/pull/25 in {spanishoddata} R package.
To get valid spatial data, use spanishoddata::spod_get_zones()
Steps to Reproduce
- Load Data
Load libraries and define data files.
library(tidyverse)
library(here)
library(DT)
gau_population_file <- here("data/raw_data/v2/zonificacion/zonificacion_GAU/poblacion_gaus.csv")Load the data and join the Large Urban Areas names to the boundaries.
gau_population <- read.delim(gau_population_file, sep = "|")Results
- Missing column names
names(gau_population)[1] "X01001"  "X2925.0"str(gau_population)'data.frame':   2085 obs. of  2 variables:
 $ X01001 : chr  "01002" "01004_AM" "01009_AM" "01010" ...
 $ X2925.0: num  10307 3005 4599 2951 4314 ...- Preview of the Large Urban Areas population table
DT::datatable(gau_population)Links to the original files
source(here("R/901-download-helpers.R"))
files <- load_latest_v2_xml()
# Filter relevant files
relevant_files <- files |> 
  filter(basename(local_path) %in% basename(c(gau_population_file)) )
# Create HTML links
relevant_files <- relevant_files |> 
  mutate(target_url = paste0("<a href='", target_url, "' target='_blank'>", target_url, "</a>"))
# Render the DT table with links
datatable(relevant_files, escape = FALSE, options = list(pageLength = 5))