Skip to contents

Reads the raw World Bank population density CSV (skipping the first 4 metadata rows), reshapes it to long format via a for loop, writes the processed data as a CSV to disk, and returns it. Uses base R functions only.

Usage

process_WB_population_density_data(PATHS)

Arguments

PATHS

List. Project paths object with components DATA_RAW and DATA_PROCESSED.

  • Reads the newest raw CSV for indicator EN.POP.DNST in file.path(PATHS$DATA_RAW, 'world_bank', 'population_density') (see download_WB_data()).

  • Writes file.path(PATHS$DATA_PROCESSED, 'world_bank', 'world_bank_population_density_data.csv'), creating the directory if needed.

Value

A data.frame with columns:

iso_code

ISO country code (character)

year

Year (integer)

pop_density

Population density (numeric, people per sq. km)

Invisibly returns the data.frame after writing the CSV.