View source: R/split_regions.R
split_regions | R Documentation |
This function takes datasets containing country records that include multiple OHI regions (macro-regions) and breaks them down into individual OHI regions. It uses population-weighted values to distribute data across the new regions. When a dataset contains both a macro-region and a sub-region, the sub-region's data is calculated by summing the population weight of the macro region and the record for the region.
split_regions(
m,
country_column = "country",
value_column = "value",
duplicate = FALSE
)
m |
The input dataset containing countries and associated values. |
country_column |
The column name in the dataset 'm' representing the countries. Defaults to "country". |
value_column |
The column name in the dataset 'm' representing the values associated with each country. Defaults to "value". |
duplicate |
A logical value. If TRUE, the values will not be split between new regions, e.g., when calculating sustainability scores. Defaults to FALSE. |
The function is built to recognize common macro-region names and their corresponding OHI regions. It's imperative for users to be aware that this function might require updates if new macro-regions or changes to OHI regions occur in the future.
Population data is used to weight the values for each newly split region. This data must be provided in the 'split_pops' data frame (external to this function). If 'duplicate' is set to TRUE, values are not divided among regions but duplicated instead.
A dataset with macro-regions split into individual OHI regions.
# This assumes existence of a dataset similar in structure to expected input and `split_pops`
# updated_data <- region_split(original_data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.