redist_iso | R Documentation |
Value redistribution from country-level (i.e., ISO 3166-1 alpha-2 codes) to principal subdivisions (i.e., ISO 3166-2 codes). See ISO 3166 Maintenance Agency.
redist_iso(
data,
iso_col,
values_col,
redist_data,
redist_iso_col,
redist_values_col
)
data |
A data frame containing the data at the country-level to redistribute. |
iso_col |
A string specifying the column name in |
values_col |
A string or vector specifying the column name(s) in
|
redist_data |
A data frame with values for each subdivision that will be used as the basis for redistribution. |
redist_iso_col |
A string specifying the column name in |
redist_values_col |
A string specifying the column name in |
This function enables redistribution of values from country-level to principal subdivisions (e.g., provinces or states), proportionally to user-supplied redistribution proportions.
Note that more than one column of values provided in the data frame data can be
redistributed at the same time. The values in columns values_col
and
redist_values_col
must be numeric and positive.
In the context of quantitative pest risk assessment (qPRA) at the entry step,
this function can be applied to redistribute the quantity of potentially infested
commodities (N_{trade}
, see ntrade()
) or the number of potential
founder populations (NPFP
, see pathway_model()
). For this purpose,
human population or consumption data from subdivisions are often used for redistribution.
A data frame with the redistributed values across the specified subnational
level. The data frame contains the columns ISO_1
with the codes at country
level, ISO_2
with the codes at subdivision level, proportion
with the
proportion according to which the values have been redistributed, and the columns
corresponding to the redistributed values with the same name specified in values_col
.
ntrade()
, pathway_model()
## Example of data redistribution in Northern American countries
data(datatrade_NorthAm)
# Selection of internal production data from January to March to be proportionally
# redistributed based on sub-national consumption data
data_ip <- datatrade_NorthAm$internal_production
data_ip <- data_ip[data_ip$time_period=="January-March",]
# consumption data at sub-national level
data_sub <- datatrade_NorthAm$consumption_iso2
# Redistribution
data_redist <- redist_iso(data = data_ip,
iso_col = "reporter",
values_col = "value",
redist_data = data_sub,
redist_iso_col = "iso_3166_2",
redist_values_col = "value")
head(data_redist)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.