derive_variables: Derive new variables from existing variables in a dataset

View source: R/model-downscale.R

derive_variablesR Documentation

Derive new variables from existing variables in a dataset

Description

This function takes in a dataframe with model data, and a variable derivation CSV table with instructions detailing what the new variables will be named, how they will be calculated, and what their units will be.

Usage

derive_variables(
  model_data_df,
  mapping = get_variable_mapping("downscale/indicators.csv"),
  drop_weighted_indicators = FALSE,
  bind_derived_data = TRUE,
  ...
)

Arguments

model_data_df

data frame with pre-processed/corrected iTEM data in the appropriate format

mapping

dataframe specifying the variables to be created, along with instructions for creating them and the units of the new variable

drop_weighted_indicators

logical (default = FALSE) indicating whether to drop "weighted indicator" variables whose purpose is to allow computation of indicator variables, generally after some aggregations or re-assignments have been performed. Weighted indicators are generally excluded from final template reporting.

bind_derived_data

logical (default = TRUE) indicating whether to return a data frame with the original model data bound to the output of this function (TRUE), or to only return the variables calculated by this function (FALSE)

Details

This function derives new variables from existing variables in the data frame. Each new variable is derived from two and only two existing variables. The operations allowed are +, *, and /. Unit conversions are applied multiplicatively. If the operation is addition and there is a unit conversion provided, the conversion is applied to the second variable in the derivation.


transportenergy/item_mip_data_processing documentation built on July 6, 2023, 7:51 p.m.