Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
fd9a552
polities
Jun 23, 2025
14bf545
data in csv
Jun 23, 2025
dca9507
polities updated
Jun 23, 2025
8b011cd
polities updated
Jun 23, 2025
4c737f2
updating polities and script
Jun 23, 2025
d9ffa64
some changes
Jun 23, 2025
dbb3585
updating polities
Jun 23, 2025
894a1fc
script short-lines
Jun 23, 2025
339de4c
script changes
Jun 23, 2025
4ad8c3f
script changes
Jun 23, 2025
0ce5ad3
Merge branch 'main' of https://github.com/eduaguilera/WHEP into aleja…
Jun 23, 2025
9a0c3a8
edited script and output
Jun 23, 2025
1a2e649
script and csv changes
Jun 23, 2025
ce6d893
polities updated
Jun 24, 2025
b6e3037
better organized polities scripts and sources
Jun 25, 2025
01b1d14
update description in polities.R document
Jun 25, 2025
b3f4c77
describing get_polities function
Jun 25, 2025
84058ed
improving code
Jun 26, 2025
3245a20
adding package to DESCRIPTION file
Jun 26, 2025
9e51521
update (polity_code)
Jul 1, 2025
bac73f8
update polity_names in cases continent-name Other
Jul 1, 2025
4bac5a4
Merge branch 'main' into alejandra/polities-harmonization
lbm364dl Jul 2, 2025
c8a45bc
Put back R 4.5.0 version
lbm364dl Jul 2, 2025
e517c1c
Merge branch 'main' into alejandra/polities-harmonization
lbm364dl Jul 24, 2025
22643ac
Add faostat_regions
lbm364dl Jul 24, 2025
a39c97e
Add united nations M49 countries
lbm364dl Jul 24, 2025
8697ebe
Rename columns
lbm364dl Jul 24, 2025
33506fe
Update whep_inputs.csv
afuenteshinojosa Jul 24, 2025
e3e2e38
adding historical m49 codes
Jul 24, 2025
2390c03
Add k_federico_tena_polities constant
lbm364dl Jul 29, 2025
95d2c68
Clean empty row
lbm364dl Jul 29, 2025
0e6b945
Add naive implementation of get_polities
lbm364dl Jul 29, 2025
c886da5
Make m49_code a padded string
lbm364dl Jul 29, 2025
689e3e0
Fix FAOSTAT regions
lbm364dl Jul 29, 2025
104631e
Use all historical M49
lbm364dl Jul 29, 2025
3d75469
Add integrity tests
lbm364dl Jul 29, 2025
cd0597a
Fix year range bug
lbm364dl Jul 29, 2025
65318ea
Make temp column removal more idiomatic
lbm364dl Jul 29, 2025
167a806
Remove 1982 start_year
lbm364dl Jul 30, 2025
3424db5
Remove virtual time boundaries for Federico Tena
lbm364dl Jul 30, 2025
10efddd
Use common name mapping table
lbm364dl Aug 1, 2025
94c92ee
Add polity absolute year range constants
lbm364dl Aug 1, 2025
23544ca
Aggregate min/max year range
lbm364dl Aug 1, 2025
778b80d
Clean get_polities
lbm364dl Aug 1, 2025
90a400e
Add faostat regions
lbm364dl Aug 4, 2025
bf950cd
Double check values in summarise columns
lbm364dl Aug 4, 2025
d3f2be7
Arrange rows by polity_name
lbm364dl Aug 4, 2025
42df197
Remove old code and leave TODOs
lbm364dl Aug 4, 2025
fe27f6f
Pass China m49 check
lbm364dl Aug 4, 2025
6891d39
Rebuild polity code
lbm364dl Aug 4, 2025
b05ccf9
Call .check_unique_value for rest of columns
lbm364dl Aug 4, 2025
fccadf2
Add polity codes mapping table
lbm364dl Aug 4, 2025
82b9390
Fix manual common name for mismatching names in same M49 code
lbm364dl Aug 4, 2025
0fd9783
Fix polity codes manually to be unique
lbm364dl Aug 4, 2025
9945545
Remove outdated comment
lbm364dl Aug 4, 2025
95b5b78
Fix common name mismatches
lbm364dl Aug 4, 2025
1963c50
Set explicit by arg
lbm364dl Aug 5, 2025
9ad541c
Fix polity codes for consistent info
lbm364dl Aug 5, 2025
b74f899
Add get_polities to _pkgdown.yml
lbm364dl Aug 5, 2025
8190fff
Use separate function to get original sources info
lbm364dl Aug 5, 2025
461f03c
Use whep polity source table to overwrite years
lbm364dl Aug 5, 2025
49b5db1
Fix common name mismatches
lbm364dl Aug 6, 2025
52e6fa9
Integrate CShapes
lbm364dl Aug 7, 2025
e421d3f
Apply suggestions from code review
lbm364dl Aug 11, 2025
53a73aa
Integrate CShapes WIP
lbm364dl Aug 7, 2025
238c054
Apply suggestions from code review
lbm364dl Aug 11, 2025
8f682be
Merge branch 'alejandra/polities-harmonization' of github.com:eduagui…
lbm364dl Aug 11, 2025
0884a24
Merge branch 'main' into alejandra/polities-harmonization
lbm364dl Aug 11, 2025
cc89964
Fix cshapes CSV remove geometry
lbm364dl Aug 11, 2025
4c13f2c
Set start_year as k_polity_first_year for federico_tena source
lbm364dl Aug 11, 2025
4845f81
Add helper to list bad code polities
lbm364dl Aug 11, 2025
f13bf36
Fix polity mismatches
lbm364dl Aug 11, 2025
534a2d2
Make get_polities output an sf object
lbm364dl Aug 12, 2025
f6b251d
Update get_polities docs
lbm364dl Aug 12, 2025
9253b88
Update dependencies
lbm364dl Aug 13, 2025
2cbc208
Add get_polity_sources docs
lbm364dl Aug 13, 2025
3742f4a
Remove old TODOs
lbm364dl Aug 13, 2025
9220344
Remove sf before testing (too slow)
lbm364dl Aug 14, 2025
28f7f38
Add useful error messages for inconsistent polity data
lbm364dl Sep 10, 2025
57351ba
Add script to run when manually updating polities
lbm364dl Sep 10, 2025
8113e80
Use only CShapes in polities table
lbm364dl Oct 28, 2025
b8be28e
Update polity code format
lbm364dl Oct 29, 2025
d5966e7
Add intermediate alias table
lbm364dl Oct 29, 2025
654e364
Create expanded alias table
lbm364dl Oct 29, 2025
c36194b
Add get_polity_code function with mismatch analysis
lbm364dl Nov 4, 2025
d86c52e
Add FAOSTAT polity mapping example
lbm364dl Nov 4, 2025
4122693
Make polities static R package data
lbm364dl Nov 5, 2025
a2f91e9
Update polities tests
lbm364dl Nov 5, 2025
0387a2c
Merge branch 'main' into alejandra/polities-harmonization
lbm364dl Nov 5, 2025
4dfe371
Remove old code
lbm364dl Nov 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Imports:
readr,
rlang,
stringr,
sf,
tidyr,
withr,
yaml,
Expand All @@ -34,14 +35,17 @@ Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
Suggests:
cshapes,
ggplot2,
googlesheets4,
here,
knitr,
lubridate,
pointblank,
rmarkdown,
testthat (>= 3.0.0),
tibble
tibble,
units
Config/testthat/edition: 3
VignetteBuilder: knitr
URL: https://eduaguilera.github.io/whep/, https://github.com/eduaguilera/whep
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export(expand_trade_sources)
export(get_bilateral_trade)
export(get_faostat_data)
export(get_feed_intake)
export(get_polity_code)
export(get_primary_production)
export(get_primary_residues)
export(get_processing_coefs)
Expand Down
12 changes: 6 additions & 6 deletions R/code_names.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ add_area_name <- function(
code_column = "area_code",
name_column = "area_name"
) {
polities <- .get_polities(name_column, code_column)
countries <- .get_countries(name_column, code_column)

table |>
dplyr::left_join(polities, {{ code_column }})
dplyr::left_join(countries, {{ code_column }})
}

#' Get area codes from area names
Expand Down Expand Up @@ -74,10 +74,10 @@ add_area_code <- function(
name_column = "area_name",
code_column = "area_code"
) {
polities <- .get_polities(name_column, code_column)
countries <- .get_countries(name_column, code_column)

table |>
dplyr::left_join(polities, {{ name_column }})
dplyr::left_join(countries, {{ name_column }})
}

#' Get commodity balance sheet item names from item codes
Expand Down Expand Up @@ -232,8 +232,8 @@ add_item_prod_code <- function(
dplyr::left_join(items, {{ name_column }})
}

.get_polities <- function(name_column, code_column) {
whep::polities |>
.get_countries <- function(name_column, code_column) {
whep::countries |>
dplyr::select(!!name_column := area_name, !!code_column := area_code)
}

Expand Down
2 changes: 2 additions & 0 deletions R/input_files.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ whep_list_file_versions <- function(file_alias) {
nanoparquet::read_parquet() |>
# Make sure it has `tbl_df` subclass, not present by default
tibble::as_tibble()
} else if (extension == "geojson") {
sf::read_sf(path)
} else {
extensions <- purrr::map(paths, fs::path_ext)
cli::cli_abort(
Expand Down
Loading
Loading