Skip to contents

This function processes the output of a cleaned model dataset by pivoting the data to a wide format and calculating the error (ERR) based on available variables. The error is calculated as the difference between `ppt`, `aet`, and other relevant variables such as `rch`, `run`, and `str`.

Usage

widen_model_data(data)

Arguments

data

A data frame containing model output. The data should have columns for `var`, `value`, `ppt`, `aet`, `run`, `str`, and optionally `rch`.

Value

A data frame in wide format with an additional column `ERR`, representing the calculated error.

Details

The function performs the following steps:

  • **Pivot Wider**: Converts the data to wide format with separate columns for each variable.

  • **Error Calculation**: Calculates the error (`ERR`) as `ppt - aet - rch - run - str` when `rch` is available, or `ppt - aet - run - str` when it's not.

  • **Filter**: Filters out rows where `divide_id` is equal to `"cat-351"`.

Note

Ensure that the input data contains the required columns: `var`, `value`, `ppt`, `aet`, `run`, `str`, and optionally `rch`.