redist_iso: Data redistribution to country subdivisions

View source: R/redist_iso.R

redist_isoR Documentation

Data redistribution to country subdivisions

Description

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.

Usage

redist_iso(
  data,
  iso_col,
  values_col,
  redist_data,
  redist_iso_col,
  redist_values_col
)

Arguments

data

A data frame containing the data at the country-level to redistribute.

iso_col

A string specifying the column name in data with the ISO 3166-1 (alpha-2) country codes.

values_col

A string or vector specifying the column name(s) in data with the values to be redistributed.

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_data that contains the destination ISO 3166-2 codes.

redist_values_col

A string specifying the column name in redist_data with the values for proportional redistribution. This will define the weights used for the redistribution.

Details

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.

Common uses

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.

Value

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.

See Also

ntrade(), pathway_model()

Examples

## 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)


qPRAentry documentation built on April 12, 2025, 1:12 a.m.