ipc_get_areas {ripc} | R Documentation |
Get areas resources from the IPC-CH API
Description
Accesses the areas resources on the IPC-CH API. Contains detailed area and
population data. If country
, year
and/or type
parameters are passed,
accesses the areas simplified API endpoint and pulls in all areas filtered to
those parameters. To get all areas for a specific analysis
and period, available on the areas/{id}/{period} advanced API endpoint,
pass in id
and period
. You cannot pass in both sets of parameters.
Usage
ipc_get_areas(
country = NULL,
year = NULL,
type = NULL,
id = NULL,
period = NULL,
return_format = c("csv", "geojson"),
api_key = NULL,
tidy_df = TRUE
)
Arguments
country |
ISO2 country code. |
year |
Single numeric year to filter analysis, calculated from the
maximum year of current period dates. If |
type |
Single string value of 'A' or 'C', corresponding to food security
conditions, either acute or chronic. If |
id |
Analysis ID. |
period |
Period code, either 'C', 'P', or 'A' for current, projection, and second projection. |
return_format |
The format that should be returned by the API. Allows
|
api_key |
IPC API key. If |
tidy_df |
If |
Details
Areas data is the typical unit of analysis in IPC-CH outputs. These are
typically administrative units (or clusters of them together). For each area,
estimates of the population in each phase is provided and a general phase
classification is assigned. Use ipc_get_population()
to get
detailed population data and classifications for all analysis periods.
See the IPC website and API documentation for more information.
Value
Data frame of IPC and CH analysis at the areas level. Refer to the IPC-CH Public API documentation for details on the returned values, with variables described in full in the extended documentation.
Tidy
When tidy_df
is TRUE
, the following changes are made to the initial
output to ensure each row represents a single area analysis, and all estimates
and values are stored as columns:
-
analysis_period_start
andanalysis_period_end
created asDate
columns from thefrom
andto
columns respectively, allocating the day of the start and end periods to be the 15th of the month. -
title
column is renamed to bearea_name
,anl_id
toanalysis_id
, andid
andaar_id
are changed toarea_id
. Duplicated rows are removed from the data frame if the return value is CSV, because the duplicates are there due to polygon geometries.
Examples
# get all areas from the simplified API
ipc_get_areas()
# get areas for specific analysis ID and period from advanced API
ipc_get_areas(id = 12856213, period = "P")
# request GeoJSON return
ipc_get_areas(id = 12856213, period = "P", return_format = "geojson")