Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8025e29
improve documentatin of growth_decomposition funs
galileukim Sep 28, 2026
9479960
update documentation
galileukim Sep 28, 2026
9612c94
port duckdb implementation #109
galileukim Oct 4, 2026
a28e35c
modify compute_growth_decomposition
galileukim Oct 4, 2026
7878906
update data files
galileukim Oct 4, 2026
ae5d4f5
refactor distribution functions.
galileukim Oct 4, 2026
4830e8d
refactor the wagebill_total functions and add arg checks #109
galileukim Oct 4, 2026
e2fa714
improve how we implement transitions
galileukim Oct 4, 2026
8195562
improve documentation
galileukim Oct 4, 2026
e8fb307
clean up data-raw
galileukim Oct 5, 2026
9ca4c12
update deflate_to_real and cpi
galileukim Oct 5, 2026
f583e3a
fix deflate_to_real
galileukim Oct 5, 2026
382d125
refactor compute_movement #109
galileukim Oct 5, 2026
1c2e944
refactor compute_movement
galileukim Oct 5, 2026
4633b26
generate standard workforce and wagebill analytics #106 #108
galileukim Oct 5, 2026
966006d
fix check issues
galileukim Oct 5, 2026
8fa1812
refactor standard_report
galileukim Oct 5, 2026
62ac3d4
make transition renderable as static
galileukim Oct 5, 2026
f68b6f0
make estimate_binwidth the default implementation
galileukim Oct 5, 2026
e3918f8
remove spielplatz from github
galileukim Oct 5, 2026
1637d6a
refactor standard report
galileukim Oct 5, 2026
cc72bd2
update renv
galileukim Oct 5, 2026
3d29648
move pkgdown assets and update license to creative commons
galileukim Oct 5, 2026
b7156e1
update documentation
galileukim Oct 5, 2026
85e6289
Increment version number to 0.4.1
galileukim Oct 5, 2026
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
11 changes: 7 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Package: govhr
Type: Package
Title: Clean and analyze data that informs human resource management
Version: 0.4.0
Title: Clean and analyze data to inform human resource management
Version: 0.4.1
Description: This package is a toolkit developed by the World Bank. It cleans, harmonizes, and analyzes human resource data with a standardized methodology.
License: MIT + file LICENSE
License: CC0
Encoding: UTF-8
LazyData: true
LazyDataCompression: xz
Expand Down Expand Up @@ -40,12 +40,15 @@ Imports:
forcats,
ggstats
Suggests:
DBI,
dbplyr,
duckdb,
readr,
testthat (>= 3.0.0),
reactable
Config/testthat/edition: 3
Depends:
R (>= 3.5)
R (>= 4.1.0)
URL: https://wb-pida-data-science-shop.github.io/govhr/
Config/Needs/website: rmarkdown, remotes, polyglotr, AleKoure/labourR, DT, tidyr, here, tibble, arrow
Authors@R: c(
Expand Down
2 changes: 0 additions & 2 deletions LICENSE

This file was deleted.

64 changes: 43 additions & 21 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,43 @@
# MIT License

Copyright (c) 2025 govhr authors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
## creative commons

# CC0 1.0 Universal

CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER.

### Statement of Purpose

The laws of most jurisdictions throughout the world automatically confer exclusive Copyright and Related Rights (defined below) upon the creator and subsequent owner(s) (each and all, an "owner") of an original work of authorship and/or a database (each, a "Work").

Certain owners wish to permanently relinquish those rights to a Work for the purpose of contributing to a commons of creative, cultural and scientific works ("Commons") that the public can reliably and without fear of later claims of infringement build upon, modify, incorporate in other works, reuse and redistribute as freely as possible in any form whatsoever and for any purposes, including without limitation commercial purposes. These owners may contribute to the Commons to promote the ideal of a free culture and the further production of creative, cultural and scientific works, or to gain reputation or greater distribution for their Work in part through the use and efforts of others.

For these and/or other purposes and motivations, and without any expectation of additional consideration or compensation, the person associating CC0 with a Work (the "Affirmer"), to the extent that he or she is an owner of Copyright and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and publicly distribute the Work under its terms, with knowledge of his or her Copyright and Related Rights in the Work and the meaning and intended legal effect of CC0 on those rights.

1. __Copyright and Related Rights.__ A Work made available under CC0 may be protected by copyright and related or neighboring rights ("Copyright and Related Rights"). Copyright and Related Rights include, but are not limited to, the following:

i. the right to reproduce, adapt, distribute, perform, display, communicate, and translate a Work;

ii. moral rights retained by the original author(s) and/or performer(s);

iii. publicity and privacy rights pertaining to a person's image or likeness depicted in a Work;

iv. rights protecting against unfair competition in regards to a Work, subject to the limitations in paragraph 4(a), below;

v. rights protecting the extraction, dissemination, use and reuse of data in a Work;

vi. database rights (such as those arising under Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, and under any national implementation thereof, including any amended or successor version of such directive); and

vii. other similar, equivalent or corresponding rights throughout the world based on applicable law or treaty, and any national implementations thereof.

2. __Waiver.__ To the greatest extent permitted by, but not in contravention of, applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and unconditionally waives, abandons, and surrenders all of Affirmer's Copyright and Related Rights and associated claims and causes of action, whether now known or unknown (including existing as well as future claims and causes of action), in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each member of the public at large and to the detriment of Affirmer's heirs and successors, fully intending that such Waiver shall not be subject to revocation, rescission, cancellation, termination, or any other legal or equitable action to disrupt the quiet enjoyment of the Work by the public as contemplated by Affirmer's express Statement of Purpose.

3. __Public License Fallback.__ Should any part of the Waiver for any reason be judged legally invalid or ineffective under applicable law, then the Waiver shall be preserved to the maximum extent permitted taking into account Affirmer's express Statement of Purpose. In addition, to the extent the Waiver is so judged Affirmer hereby grants to each affected person a royalty-free, non transferable, non sublicensable, non exclusive, irrevocable and unconditional license to exercise Affirmer's Copyright and Related Rights in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "License"). The License shall be deemed effective as of the date CC0 was applied by Affirmer to the Work. Should any part of the License for any reason be judged legally invalid or ineffective under applicable law, such partial invalidity or ineffectiveness shall not invalidate the remainder of the License, and in such case Affirmer hereby affirms that he or she will not (i) exercise any of his or her remaining Copyright and Related Rights in the Work or (ii) assert any associated claims and causes of action with respect to the Work, in either case contrary to Affirmer's express Statement of Purpose.

4. __Limitations and Disclaimers.__

a. No trademark or patent rights held by Affirmer are waived, abandoned, surrendered, licensed or otherwise affected by this document.

b. Affirmer offers the Work as-is and makes no representations or warranties of any kind concerning the Work, express, implied, statutory or otherwise, including without limitation warranties of title, merchantability, fitness for a particular purpose, non infringement, or the absence of latent or other defects, accuracy, or the present or absence of errors, whether or not discoverable, all to the greatest extent permissible under applicable law.

c. Affirmer disclaims responsibility for clearing rights of other persons that may apply to the Work or any use thereof, including without limitation any person's Copyright and Related Rights in the Work. Further, Affirmer disclaims responsibility for obtaining any necessary consents, permissions or other rights required for any use of the Work.

d. Affirmer understands and acknowledges that Creative Commons is not a party to this document and has no duty or obligation with respect to this CC0 or use of the Work.
54 changes: 38 additions & 16 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Generated by roxygen2: do not edit by hand

S3method(compute_growth_decomposition,data.frame)
S3method(compute_growth_decomposition,tbl_dbi)
S3method(compute_headcount,data.frame)
S3method(compute_headcount,tbl_dbi)
S3method(compute_movement,data.frame)
S3method(compute_movement,tbl_dbi)
S3method(compute_percentile,data.frame)
S3method(compute_percentile,tbl_dbi)
S3method(compute_transition,data.frame)
S3method(compute_transition,tbl_dbi)
S3method(compute_wage,data.frame)
S3method(compute_wage,tbl_dbi)
S3method(compute_wagebill,data.frame)
S3method(compute_wagebill,tbl_dbi)
export(add_contract_to_event)
export(apply_baseline_index)
export(classify_personnel_event)
Expand All @@ -12,7 +26,6 @@ export(compute_coverage)
export(compute_cross_section)
export(compute_cross_section_summary)
export(compute_decile)
export(compute_density)
export(compute_fastchange)
export(compute_fastshare)
export(compute_fastsummary)
Expand All @@ -21,18 +34,23 @@ export(compute_global_coverage)
export(compute_growth)
export(compute_growth_decomposition)
export(compute_growth_summary)
export(compute_headcount)
export(compute_movement)
export(compute_movement_cost)
export(compute_pension_ratio)
export(compute_percentile)
export(compute_quantile)
export(compute_record_consistency)
export(compute_service_table)
export(compute_time_trend)
export(compute_transition)
export(compute_trend_summary)
export(compute_value_consistency)
export(compute_wage)
export(compute_wage_decomposition)
export(compute_wagebill)
export(compute_workforce_movement)
export(compute_wagebill_analytics)
export(compute_workforce_analytics)
export(convert_constant_ppp)
export(count_entity)
export(count_unique)
Expand All @@ -41,10 +59,8 @@ export(cv)
export(dedup_values)
export(define_fns)
export(deflate_to_real)
export(detect_career_transition)
export(detect_inconsistent_cols)
export(detect_personnel_event)
export(detect_reallocation)
export(detect_retirement)
export(estimate_decrement_rates)
export(estimate_exit_rates)
Expand All @@ -59,7 +75,7 @@ export(fix_retirement_age)
export(fix_salary_components)
export(fix_underage_workers)
export(fix_working_hours)
export(generate_hr_report)
export(generate_standard_report)
export(get_data360_api)
export(get_metadata360)
export(ggplot_coef)
Expand Down Expand Up @@ -102,12 +118,13 @@ importFrom(collapse,fquantile)
importFrom(data.table,
":=",
.N,
CJ,
.SD,
as.data.table,
copy,
data.table,
dcast,
fcase,
fcoalesce,
fifelse,
is.data.table,
melt,
Expand All @@ -128,6 +145,8 @@ importFrom(dplyr,
any_of,
arrange,
case_when,
coalesce,
collect,
count,
desc,
distinct,
Expand All @@ -136,9 +155,12 @@ importFrom(dplyr,
first,
group_by,
if_else,
inner_join,
intersect,
join_by,
lag,
last,
lead,
left_join,
mutate,
n,
Expand All @@ -148,13 +170,15 @@ importFrom(dplyr,
rename,
row_number,
select,
semi_join,
slice_head,
slice_tail,
starts_with,
summarise,
symdiff,
ungroup,
union
union,
union_all
)
importFrom(dtplyr,lazy_dt)
importFrom(fixest,fixef)
Expand Down Expand Up @@ -218,6 +242,7 @@ importFrom(igraph,gorder)
importFrom(janitor,clean_names)
importFrom(jsonlite,fromJSON)
importFrom(lubridate,
floor_date,
years,
ymd
)
Expand All @@ -226,9 +251,10 @@ importFrom(plotly,
plot_ly
)
importFrom(purrr,
map2_chr,
map,
map_dbl,
map_dfr,
reduce,
set_names
)
importFrom(rlang,
Expand All @@ -238,14 +264,15 @@ importFrom(rlang,
as_label,
as_name,
as_string,
check_dots_empty,
enquo,
enquos,
ensym,
expr,
is_formula,
sym
sym,
syms
)
importFrom(rmarkdown,render)
importFrom(scales,
cut_short_scale,
label_number,
Expand All @@ -270,10 +297,5 @@ importFrom(tibble,
tibble
)
importFrom(tidygraph,as_tbl_graph)
importFrom(tidyr,
complete,
nest,
nesting,
pivot_wider
)
importFrom(tidyr,pivot_wider)
importFrom(tidyselect,eval_select)
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# govhr 0.4.1
This release:
- Standardizes an architecture for workforce and wage bill analytics.
- Increases computational performance by implementing backend duckplyr and data.table APIs.
- Cleans up the repository, including removing spielplatz folder.
- Updates and streamlines documentation.

# govhr 0.4.0
This release:
- Introduces novel wage bill modelling and demographic analysis.
Expand Down
70 changes: 66 additions & 4 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,68 @@
"macro_indicators"


#' Monthly consumer price index (CPI) by country
#'
#' The monthly consumer price index (CPI) for all items, by country, from the
#' International Monetary Fund (IMF). A CPI tracks how the prices of everyday
#' goods and services change over time, so it can turn nominal wages into
#' real wages that are comparable across months and years. It is the data
#' underlying [deflate_to_real()].
#'
#' @format A tibble with 66,742 rows and 5 columns, one row per country and
#' month:
#' \describe{
#' \item{ref_date}{First day of the month the CPI refers to (`Date`).}
#' \item{country_code}{ISO3 country code.}
#' \item{cpi}{CPI rebased so that December 2021 = 100, or the closest
#' available month for the 15 countries listed under Details.}
#' \item{cpi_national}{CPI as published by the IMF, relative to the
#' country's own reference period (see `cpi_national_base_period`).}
#' \item{cpi_national_base_period}{Reference period of `cpi_national`, in
#' IMF notation: `"2019M6"` means June 2019 = 100, `"2010A"` means the
#' 2010 annual average = 100.}
#' }
#'
#' @details
#' Covers 191 countries. How far back each country's series goes varies, and
#' some countries have gaps. `cpi_national` uses a different reference period
#' in each country, while `cpi` puts every country on the same one (December
#' 2021), which makes inflation trends easier to compare side by side. Within
#' a single country, ratios of either column give the same inflation rate.
#'
#' **Countries with a different base month.** 15 countries report no CPI for
#' December 2021, mostly because their series stops earlier. For these, `cpi`
#' is rebased to the month closest to December 2021 instead (`cpi` = 100 in
#' that month):
#'
#' | Country | Base month | Country | Base month |
#' |---|---|---|---|
#' | ABW (Aruba) | 2020-02 | MTQ (Martinique) | 2018-08 |
#' | AUS (Australia) | 2024-04 | NCL (New Caledonia) | 2017-01 |
#' | COD (DR Congo) | 2017-02 | NRU (Nauru) | 2013-08 |
#' | CUW (Curacao) | 2020-02 | SWZ (Eswatini) | 2020-09 |
#' | GLP (Guadeloupe) | 2016-12 | SXM (Sint Maarten) | 2017-12 |
#' | MMR (Myanmar) | 2020-11 | SYR (Syria) | 2019-12 |
#' | VEN (Venezuela) | 2016-12 | VGB (British Virgin Islands) | 2017-05 |
#' | YEM (Yemen) | 2015-12 | | |
#'
#' Australia is the one country whose series starts after December 2021
#' rather than ending before it: the IMF's monthly series for Australia
#' begins in April 2024.
#'
#' Because the base month differs, the level of `cpi` for these countries is
#' not directly comparable with other countries. Inflation between any two
#' months (the ratio of their `cpi` values) is unaffected, so
#' [deflate_to_real()] works the same for every country.
#'
#' To refresh the data, run `data-raw/cpi.R`.
#'
#' @source IMF Consumer Price Index (CPI) dataset, series
#' `<country>.CPI._T.IX.M` (all items, index, monthly), via the IMF SDMX 3.0
#' API: <https://data.imf.org/>
"cpi"


#' International Standard Classification of Occupations (ISCO-08)
#'
#' A dataset containing the structure of the International
Expand Down Expand Up @@ -295,7 +357,7 @@
#' The dataset follows the GovHR contract module data dictionary and is intended
#' for workforce analytics, payroll analysis, and personnel microsimulation.
#'
#' @format A data frame with 16,434 rows and 19 variables:
#' @format A data frame with 14,773 rows and 19 variables:
#' \describe{
#' \item{contract_id}{Unique identifier assigned to each contract.}
#' \item{personnel_id}{Unique identifier assigned to each worker.}
Expand Down Expand Up @@ -352,7 +414,7 @@
#' intended for workforce analytics, demographic analysis, and personnel
#' microsimulation.
#'
#' @format A data frame with 15,681 rows and 11 variables:
#' @format A data frame with 14,106 rows and 11 variables:
#' \describe{
#' \item{personnel_id}{Unique identifier assigned to each worker.}
#' \item{ref_date}{Reference date of the HRMIS record.}
Expand Down Expand Up @@ -400,7 +462,7 @@
#' intended to support organizational analysis, workforce reporting, and
#' aggregation of personnel and contract records.
#'
#' @format A data frame with 65 rows and 6 variables:
#' @format A data frame with 570 rows and 7 variables:
#' \describe{
#' \item{est_name_native}{Official establishment name in the native language (Portuguese).}
#' \item{est_id}{Unique identifier assigned to each establishment.}
Expand Down Expand Up @@ -601,7 +663,7 @@ NULL
#' `contract_id`–`ref_date`–`allowance_type` combination. Monetary values are
#' reported in local currency units (LCU).
#'
#' @format A data frame with 60,430 rows and 5 variables:
#' @format A data frame with 55,600 rows and 5 variables:
#' \describe{
#' \item{contract_id}{Character. Unique identifier for the employment
#' contract associated with the allowance.}
Expand Down
Loading
Loading