Estimate the rate of change or first derivative of the raw mean daily streamflow or the smoothed cubic spline fit between time and mean daily streamflow.

## Usage

`rate_of_change(discharge, dates, smooth = TRUE)`

## Arguments

- discharge
numeric vector of mean daily discharges

- dates
vector of dates corresponding to daily discharge measurements.
Must be class `"Date"`

.

- smooth
logical indicating if the first derivative is calculated using a cubic smoothing spline function. Defaults is `TRUE`

.

## Value

Numeric vector with the estimated streamflow rate of change.

## Examples

```
## calculate the first deriv of the smoothed function between Date and streamflow
rate <- rate_of_change(lavaca$Flow, lavaca$Date)
head(rate)
## Return the first deriv on raw measurements
rate2 <- rate_of_change(lavaca$Flow, lavaca$Date, smooth = FALSE)
head(rate2)
```