The simple use for the idmc
package is to retrieve the
data from the API directly into R.
df <- idmc_get_data()
df
#> # A tibble: 32,622 × 37
#> id country iso3 latitude longitude centroid role displacement_type
#> <int> <chr> <chr> <dbl> <dbl> <chr> <chr> <chr>
#> 1 162292 Ukraine UKR 48.0 37.8 [47.96067, 3… Reco… Conflict
#> 2 162336 Ukraine UKR 47.9 35.2 [47.85334, 3… Reco… Conflict
#> 3 162291 Ukraine UKR 48.0 37.8 [47.96067, 3… Reco… Conflict
#> 4 162290 Ukraine UKR 48.0 37.8 [47.96067, 3… Reco… Conflict
#> 5 162289 Ukraine UKR 48.0 37.8 [47.96067, 3… Reco… Conflict
#> 6 162334 Ukraine UKR 47.6 35.8 [47.562408, … Reco… Conflict
#> 7 162244 China CHN 31.2 121. [31.232269, … Tria… Disaster
#> 8 162288 Ukraine UKR 48.0 37.8 [47.96067, 3… Reco… Conflict
#> 9 162296 Ukraine UKR 52.0 33.2 [52.01416, 3… Reco… Conflict
#> 10 162335 Ukraine UKR 47.7 35.4 [47.703671, … Reco… Conflict
#> # ℹ 32,612 more rows
#> # ℹ 29 more variables: qualifier <chr>, figure <int>, displacement_date <date>,
#> # displacement_start_date <date>, displacement_end_date <date>, year <int>,
#> # event_id <int>, event_name <chr>, event_codes <chr>,
#> # event_code_types <chr>, event_start_date <date>, event_end_date <date>,
#> # category <chr>, subcategory <chr>, type <chr>, subtype <chr>,
#> # standard_popup_text <chr>, event_url <chr>, event_info <chr>, …
This data frame, with variables described in the API
documentation, includes 1 row per event. We can normalize this to
daily displacement, assuming uniform distribution of displacement
between start and end date, for all countries and type of displacement.
idmc_transform_daily()
.
idmc_transform_daily(df)
#> # A tibble: 749,690 × 5
#> iso3 country displacement_type date displacement_daily
#> <chr> <chr> <chr> <date> <dbl>
#> 1 AB9 Abyei Area Conflict 2018-01-01 0
#> 2 AB9 Abyei Area Conflict 2018-01-02 0
#> 3 AB9 Abyei Area Conflict 2018-01-03 0
#> 4 AB9 Abyei Area Conflict 2018-01-04 0
#> 5 AB9 Abyei Area Conflict 2018-01-05 0
#> 6 AB9 Abyei Area Conflict 2018-01-06 0
#> 7 AB9 Abyei Area Conflict 2018-01-07 0
#> 8 AB9 Abyei Area Conflict 2018-01-08 0
#> 9 AB9 Abyei Area Conflict 2018-01-09 0
#> 10 AB9 Abyei Area Conflict 2018-01-10 0
#> # ℹ 749,680 more rows
While there are a few other parameters you can play around with in these functions, this is the primary purpose of this simple package.