Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Load and Wrangle IDMC Displacement Data

License

NotificationsYou must be signed in to change notification settings

OCHA-DAP/idmc

Repository files navigation

R-CMD-checkLifecycle: experimental

The goal of idmc is to provide easy access and wrangling of displacementdata stored in theInternal Displacement MonitoringCentre’s (IDMC) displacementdatabase. The data is retrieved from theInternal Displacement UpdateAPI.

Installation

You can install idmc from CRAN:

install.packages("idmc")

Alternatively, you can install the development version of idmc fromGitHub with:

# install.packages("devtools")devtools::install_github("OCHA-DAP/idmc")

API URL

You need an IDMC endpoint URL to access the API. These are provided byIDMC. The easiest way to save the URL for use in your R sessions is byusingusethis::edit_r_environ() and adding the variable there as:

IDMC_API="Insert API URL here"

Usage

library(idmc)

The simple use for theidmc package is to retrieve the data from theAPI 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 theAPIdocumentation,includes 1 row per event. We can normalize this to daily displacement,assuming uniform distribution of displacement between start and enddate, for all countries and type of displacement.idmc_transform_daily().

idmc_transform_daily(df)#> # A tibble: 71,750 × 5#>    iso3  country    displacement_type date       displacement_daily#>    <chr> <chr>      <chr>             <date>                  <dbl>#>  1 AB9   Abyei Area Conflict          2020-01-20               600#>  2 AB9   Abyei Area Conflict          2020-01-21               600#>  3 AB9   Abyei Area Conflict          2020-01-22               600#>  4 AB9   Abyei Area Conflict          2020-01-23               600#>  5 AB9   Abyei Area Conflict          2020-01-24               600#>  6 AB9   Abyei Area Conflict          2020-01-25               600#>  7 AB9   Abyei Area Conflict          2020-01-26               600#>  8 AB9   Abyei Area Conflict          2020-01-27               600#>  9 AB9   Abyei Area Conflict          2020-04-13               260#> 10 AB9   Abyei Area Conflict          2022-02-10              9937.#> # ℹ 71,740 more rows

While there are a few other parameters you can play around with in thesefunctions, this is the primary purpose of this simple package.

About

Load and Wrangle IDMC Displacement Data

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp