split_regions: Split Macro-Regions to OHI Regions

View source: R/split_regions.R

split_regionsR Documentation

Split Macro-Regions to OHI Regions

Description

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.

Usage

split_regions(
  m,
  country_column = "country",
  value_column = "value",
  duplicate = FALSE
)

Arguments

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.

Details

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.

Value

A dataset with macro-regions split into individual OHI regions.

Examples

# This assumes existence of a dataset similar in structure to expected input and `split_pops`
# updated_data <- region_split(original_data)


OHI-Science/ohicore documentation built on Dec. 10, 2023, 5:45 a.m.