Missing column names in municipal population CSV

tabular data
metadata
importance: low
Author
Published

July 17, 2024

Modified

August 17, 2024


Status: ✅ resolved

Importance: 1 - low

Summary: CSV file with municipal 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()

install.packages("spanishoddata",
  repos = c("https://e-kotov.r-universe.dev", "https://cloud.r-project.org"))

zones <- spanishoddata::spod_get_zones("municip", ver = 2)

Steps to Reproduce

  1. Load Data

Load libraries and define data files.

library(tidyverse)
library(here)
library(DT)

municipality_population_file <- here("data/raw_data/v2/zonificacion/zonificacion_municipios/poblacion_municipios.csv")

Load the data and join the municipality names to the boundaries.

municipality_population <- read.delim(municipality_population_file, sep = "|")

Results

  1. Missing column names
names(municipality_population)
[1] "X01001"  "X2925.0"
str(municipality_population)
'data.frame':   2617 obs. of  2 variables:
 $ X01001 : chr  "01002" "01004_AM" "01009_AM" "01010" ...
 $ X2925.0: num  10307 3005 4599 2951 4314 ...
  1. Preview of the municipal population table
DT::datatable(municipality_population)