Skip to contents

This function computes the correlation between changes in well water levels and streamflow for each divide (basin). It calculates standard deviations of well water levels and streamflow, computes correlation coefficients, and merges these correlations back into the original dataset.

Usage

Correlation(x)

Arguments

x

A data frame containing columns for `Divide`, `mean_change_mm` (change in well water level), and `deltaSTR` (change in streamflow).

Value

A data frame where correlation coefficients between well water level changes and streamflow are computed for each divide. The output includes:

Divide

The divide ID.

correlation

The correlation coefficient between well water level changes and streamflow for each divide.

plot_titles

A character column containing plot titles with divide information and the rounded correlation values.

Details

The `Correlation` function performs the following steps:

  • Groups the input data by `Divide`.

  • Computes the standard deviations of well water level changes (`mean_change_mm`) and streamflow (`deltaSTR`) for each divide.

  • Calculates the correlation between these variables for each divide, handling cases where standard deviations are zero by returning `NA` for the correlation.

  • Merges the calculated correlation values back into the original dataset.

  • Creates a `plot_titles` column with divide information and the rounded correlation value for plotting purposes.