| Title: | Fetching Data from the 'Displacement Tracking Matrix' |
|---|---|
| Description: | Allows humanitarian community, academia, media, government, and non-governmental organizations to utilize the data collected by the 'Displacement Tracking Matrix' (<https://dtm.iom.int>), a unit in the International Organization for Migration. This also provides non-sensitive Internally Displaced Person figures, aggregated at the country, Admin 1 (states, provinces, or equivalent), and Admin 2 (smaller administrative areas) levels. |
| Authors: | Luong Bang Tran [aut], Assad Asil Companioni [aut, cre], Displacement Tracking Matrix [cph] |
| Maintainer: | Assad Asil Companioni <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0.9000 |
| Built: | 2026-05-12 07:07:44 UTC |
| Source: | https://github.com/displacement-tracking-matrix/dtmapi-r |
Retrieve all countries for which DTM data is publicly available through the API.
get_all_countries()get_all_countries()
A data frame containing the list of all countries.
countries_df <- get_all_countries() head(countries_df)countries_df <- get_all_countries() head(countries_df)
Retrieve all operations for which DTM data is publicly available through the API.
get_all_operations()get_all_operations()
A data frame containing the list of all operations.
# Fetch all operations operations_df <- get_all_operations() head(operations_df)# Fetch all operations operations_df <- get_all_operations() head(operations_df)
Retrieve IDP data at Admin 0 level based on specified parameters. At least one of the following parameters must be provided: Operation, CountryName, or Admin0Pcode.
get_idp_admin0_data( Operation = NULL, CountryName = NULL, Admin0Pcode = NULL, FromReportingDate = NULL, ToReportingDate = NULL, FromRoundNumber = 0, ToRoundNumber = 0 )get_idp_admin0_data( Operation = NULL, CountryName = NULL, Admin0Pcode = NULL, FromReportingDate = NULL, ToReportingDate = NULL, FromRoundNumber = 0, ToRoundNumber = 0 )
Operation |
Optional; Name of the DTM operation for which the data was collected. |
CountryName |
Optional; Name of the country where the data was collected. |
Admin0Pcode |
Optional; Country code (ISO 3166-1 alpha-3). |
FromReportingDate |
Optional; Start date for the reporting period (format: 'YYYY-MM-DD'). |
ToReportingDate |
Optional; End date for the reporting period (format: 'YYYY-MM-DD'). |
FromRoundNumber |
Optional; Starting round number for the data collection range. |
ToRoundNumber |
Optional; Ending round number for the data collection range. |
A data frame containing the IDP Admin0 data matching the specified criteria.
# Fetch IDP data at Admin Level 0 idp_admin0_df <- get_idp_admin0_data(CountryName = "Ethiopia", FromRoundNumber = 1, ToRoundNumber = 10) head(idp_admin0_df)# Fetch IDP data at Admin Level 0 idp_admin0_df <- get_idp_admin0_data(CountryName = "Ethiopia", FromRoundNumber = 1, ToRoundNumber = 10) head(idp_admin0_df)
Retrieve IDP data at Admin 1 level based on specified parameters. At least one of the following parameters must be provided: Operation, CountryName, or Admin0Pcode.
get_idp_admin1_data( Operation = NULL, CountryName = NULL, Admin0Pcode = NULL, Admin1Name = NULL, Admin1Pcode = NULL, FromReportingDate = NULL, ToReportingDate = NULL, FromRoundNumber = 0, ToRoundNumber = 0 )get_idp_admin1_data( Operation = NULL, CountryName = NULL, Admin0Pcode = NULL, Admin1Name = NULL, Admin1Pcode = NULL, FromReportingDate = NULL, ToReportingDate = NULL, FromRoundNumber = 0, ToRoundNumber = 0 )
Operation |
Optional; Name of the DTM operation for which the data was collected. |
CountryName |
Optional; Name of the country where the data was collected. |
Admin0Pcode |
Optional; Country code (ISO 3166-1 alpha-3). |
Admin1Name |
Optional; Name of level 1 administrative boundaries. |
Admin1Pcode |
Optional; Place code of level 1 administrative boundaries. |
FromReportingDate |
Optional; Start date for the reporting period (format: 'YYYY-MM-DD'). |
ToReportingDate |
Optional; End date for the reporting period (format: 'YYYY-MM-DD'). |
FromRoundNumber |
Optional; Starting round number for the data collection range. |
ToRoundNumber |
Optional; Ending round number for the data collection range. |
A data frame containing the IDP Admin1 data matching the specified criteria.
# Fetch IDP data at Admin Level 1 idp_admin1_df <- get_idp_admin1_data(CountryName = "Sudan", Admin1Name = "Blue Nile") head(idp_admin1_df)# Fetch IDP data at Admin Level 1 idp_admin1_df <- get_idp_admin1_data(CountryName = "Sudan", Admin1Name = "Blue Nile") head(idp_admin1_df)
Retrieve IDP data at Admin 2 level based on specified parameters. At least one of the following parameters must be provided: Operation, CountryName, or Admin0Pcode.
get_idp_admin2_data( Operation = NULL, CountryName = NULL, Admin0Pcode = NULL, Admin1Name = NULL, Admin1Pcode = NULL, Admin2Name = NULL, Admin2Pcode = NULL, FromReportingDate = NULL, ToReportingDate = NULL, FromRoundNumber = 0, ToRoundNumber = 0 )get_idp_admin2_data( Operation = NULL, CountryName = NULL, Admin0Pcode = NULL, Admin1Name = NULL, Admin1Pcode = NULL, Admin2Name = NULL, Admin2Pcode = NULL, FromReportingDate = NULL, ToReportingDate = NULL, FromRoundNumber = 0, ToRoundNumber = 0 )
Operation |
Optional; Name of the DTM operation for which the data was collected. |
CountryName |
Optional; Name of the country where the data was collected. |
Admin0Pcode |
Optional; Country code (ISO 3166-1 alpha-3). |
Admin1Name |
Optional; Name of level 1 administrative boundaries. |
Admin1Pcode |
Optional; Place code of level 1 administrative boundaries. |
Admin2Name |
Optional; Name of level 2 administrative boundaries. |
Admin2Pcode |
Optional; Place code of level 2 administrative boundaries. |
FromReportingDate |
Optional; Start date for the reporting period (format: 'YYYY-MM-DD'). |
ToReportingDate |
Optional; End date for the reporting period (format: 'YYYY-MM-DD'). |
FromRoundNumber |
Optional; Starting round number for the data collection range. |
ToRoundNumber |
Optional; Ending round number for the data collection range. |
A data frame containing the IDP Admin2 data matching the specified criteria.
# Fetch IDP data at Admin Level 2 idp_admin2_df <- get_idp_admin2_data(Operation = "Yemen conflict", CountryName = "Yemen") head(idp_admin2_df)# Fetch IDP data at Admin Level 2 idp_admin2_df <- get_idp_admin2_data(Operation = "Yemen conflict", CountryName = "Yemen") head(idp_admin2_df)
The DTM API subscription key is returned, provided that it is available in
the R session as an environment variable. Users will usually need to set
the DTM_SUBSCRIPTION_KEY environment variable through a .Renviron file (or
other means) or by calling set_subscription_key().
get_subscription_key()get_subscription_key()
On the other hand, if the TESTTHAT environment variable is true, indicating that unit tests are being run by the package maintainers, then the subscription key is returned through different means.
A string representing a given subscription key for the DTM API.
## Not run: # Generally, calling set_subscription_key() without the key as an argument is best, # as the user can then be prompted to input the key without typing it directly # into the console, making it more secure and less likely to exposed. set_subscription_key() ## End(Not run)## Not run: # Generally, calling set_subscription_key() without the key as an argument is best, # as the user can then be prompted to input the key without typing it directly # into the console, making it more secure and less likely to exposed. set_subscription_key() ## End(Not run)
The API subscription key will be stored as an environment variable named "DTM_SUBSCRIPTION_KEY".
set_subscription_key(..., key = NULL)set_subscription_key(..., key = NULL)
... |
Any argument here is ignored. It exists solely to discourage typing in the
subscription key directly,
e.g. |
key |
Either NULL or a string representing the key. NULL is preferable: using it will prompt the user to type the subscription key in a graphical user interface that masks it. |
Nothing. Creates / overwrites an environment variable as a side effect.
## Not run: # Generally, calling set_subscription_key() without the key as an argument is best, # as the user can then be prompted to input the key without typing it directly # into the console, making it more secure and less likely to exposed. set_subscription_key() ## End(Not run)## Not run: # Generally, calling set_subscription_key() without the key as an argument is best, # as the user can then be prompted to input the key without typing it directly # into the console, making it more secure and less likely to exposed. set_subscription_key() ## End(Not run)