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: 20,289 × 26
#> id country iso3 latitude longitude centroid displacement_type qualifier
#> <int> <chr> <chr> <dbl> <dbl> <chr> <chr> <chr>
#> 1 120233 United … USA 31.1 -93.2 [31.114… Disaster total
#> 2 120186 United … USA 39.1 -94.5 [39.092… Disaster total
#> 3 120191 United … USA 44.9 -123. [44.912… Disaster total
#> 4 120197 Dominic… DOM 19.3 -70.0 [19.281… Disaster total
#> 5 120195 Dominic… DOM 19.3 -70.0 [19.281… Disaster total
#> 6 120110 France FRA 44.5 6.47 [44.498… Disaster more than
#> 7 120124 Indones… IDN -7.46 109. [-7.458… Disaster total
#> 8 120188 United … USA 30.7 -93.5 [30.706… Disaster total
#> 9 120208 Viet Nam VNM 22.8 105. [22.779… Disaster total
#> 10 120047 Philipp… PHL 6.85 124. [6.8514… Disaster total
#> # ℹ 20,279 more rows
#> # ℹ 18 more variables: figure <int>, displacement_date <date>,
#> # displacement_start_date <date>, displacement_end_date <date>, year <int>,
#> # event_name <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>,
#> # standard_info_text <chr>, old_id <chr>, created_at <date>
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: 611,660 × 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
#> # ℹ 611,650 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.