psgc provides access to the Philippine Standard Geographic Code (PSGC) — the official classification system for geographic areas in the Philippines published by the Philippine Statistics Authority (PSA). It bundles 12 releases (Q1 2023 – Q1 2026) and exposes them through a small, consistent set of functions.
Installation
# Install from CRAN
install.packages("psgc")
# Or install the development version from GitHub
# install.packages("pak")
pak::pak("yng-me/psgc")Overview
| Function | What it does |
|---|---|
list_releases() |
List all bundled PSA releases |
latest_release() |
Name of the most recent release |
get_psgc() |
Full PSGC table, with optional level filter and population |
psgc_info() |
Metadata for one or more PSGC codes |
get_population() |
Census population figures (long or wide) |
map_psgc() |
Trace codes forward across releases |
Every function defaults to the latest release. Pass a release argument to work with older data.
Usage
Population data
# Long format (default)
get_population(geographic_level = "Region", details = TRUE)
#> psgc_code area_name geographic_level year population
#> 1 0100000000 Region I - Ilocos Region Reg 2015 5026128
#> ...
# Wide format — one row per area, one column per census year
get_population(geographic_level = "Region", details = TRUE, wide = TRUE)
#> psgc_code area_name geographic_level population_2015 population_2020 population_2024
#> 1 0100000000 Region I - Ilocos Region Reg 5026128 5301139 5696141
#> ...Attach population to the PSGC table
regions <- get_psgc(
geographic_level = "Region",
include_population_data = TRUE
)
# population_data is a nested list-column — one data frame per row
regions$population_data[[1]]
#> population year
#> 1 5026128 2015
#> 2 5301139 2020
#> 3 5696141 2024Track codes across releases
# What is the current code for this 2023-era code?
map_psgc("0100000000")
# Map to a specific target release
map_psgc("0100000000", to = "Q4_2023")mapping_type tells you what changed: "direct" (unchanged), "renumbered", "split", "merged", or "abolished" (new code will be NA).
Geographic levels
| Code | Aliases accepted | Description |
|---|---|---|
Reg |
Region, region, REG, … |
Region |
Prov |
Province, province, PROV, … |
Province |
City |
City, city, CITY
|
City |
Mun |
Municipality, municipal, MUN, … |
Municipality |
SubMun |
Sub-Municipality, SubMun, sub_mun, … |
Sub-municipality |
Bgy |
Barangay, Brgy, barangay, BGY, … |
Barangay |
| (special) |
city_mun, City-Municipality, … |
Cities and Municipalities |
Bundled releases
list_releases()
#> [1] "Q1_2023" "Q4_2023" "April_2024" "Q2_2024" "Q3_2024"
#> [6] "Q4_2024" "Q1_2025" "Q2_2025" "July_2025" "Q3_2025"
#> [11] "Q4_2025" "Q1_2026"