Title: | Load and Wrangle IDMC Displacement Data |
---|---|
Description: | Utilities to work with data from the Internal Displacement Monitoring Centre (IDMC) (<https://www.internal-displacement.org/>), with convenient functions for loading events data from the IDMC API and transforming events data to daily displacement estimates. |
Authors: | Seth Caldwell [aut, cre, cph] |
Maintainer: | Seth Caldwell <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.3.1 |
Built: | 2025-02-06 04:56:44 UTC |
Source: | https://github.com/ocha-dap/idmc |
idmc_get_data()
calls the IDMC API to retrieve displacement data. The data
is converted from JSON to a data frame, date columns converted to Date
types, and returned as a dplyr::tibble.
idmc_get_data(api_url = NULL)
idmc_get_data(api_url = NULL)
api_url |
URL to the IDMC API. If |
Tibble of displacement data. Description of the data frame variables are included in the documentation for the IDMC IDU API. # nolint
idmc_get_data()
idmc_get_data()
idmc_transform_daily()
transforms event data from the IDMC API (accessed
through idmc_get_data()
). For each event, identified by an event_id
,
potentially duplicated data is filtered out. If there are Recommended figure
rows based on the role
column, then only those are kept. If there are no
recommended figures, then only the latest update to the event_id
data is
kept, using created_at
to find latest updates.
idmc_transform_daily( df, min_date = as.Date("2018-01-01"), max_date = Sys.Date(), filter_min_date = TRUE )
idmc_transform_daily( df, min_date = as.Date("2018-01-01"), max_date = Sys.Date(), filter_min_date = TRUE )
df |
Event displacement data frame, generated from |
min_date |
Date to backfill displacement data to. By default, |
max_date |
Date to extrapolate all data to, filling with |
filter_min_date |
If |
The data for each event is spread out between the start and end date, with the total displacement uniformly distributed across all days. For each country and displacement type (conflict, disaster, or other), all displacement on a day is summed up to create a total daily displacement figure.
By default, data is backfilled for all countries and displacement types to the first reported date in the IDMC dataset. Data is always infilled with 0 between start and end dates.
Data frame of daily displacement with the following columns:
Country ISO3 code.
Country or area name.
Type of displacement.
Date.
Daily level of displacement.
idmc_get_data() %>% idmc_transform_daily()
idmc_get_data() %>% idmc_transform_daily()