Usage

api_envvar_available <- !is.na(Sys.getenv("IDMC_API", unset = NA))
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  eval = api_envvar_available
)
message("`IDMC_API` env variable not set, so code chunks will not be evaluated.")  
library(idmc)

The simple use for the idmc package is to retrieve the data from the API directly into R.

df <- idmc_get_data()
df

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)

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



Try the idmc package in your browser

Any scripts or data that you put into this service are public.

idmc documentation built on Sept. 30, 2024, 9:33 a.m.