Applies the which.max function and returns an xts object with the maximum value and associated date.

rvn_which_max_xts(x)

Arguments

x

xts object to apply which.max to

Value

xts object with max value and corresponding date

Details

Acts as the which.max function, applicable to xts objects and returning values in an xts format.

Note that when deploying the rvn_apply_wyearly function, the dates are overwritten and the dates of the water year ending periods are displayed rather than the event dates. In order to obtain the corresponding dates when using the rvn_apply_wyearly function, please use rvn_apply_wyearly_which_max_xts.

See also

which.max base which.max function rvn_apply_wyearly_which_max_xts for using apply_wyearly with the rvn_which_max_xts function

Examples

data(rvn_hydrograph_data)

# obtain the peak observed flow and the corresponding date
rvn_which_max_xts(rvn_hydrograph_data$hyd$Sub43_obs)
#>            Sub43_obs
#> 2004-03-08       258

# note that the usual rvn_apply_wyearly does not provide the correct dates with this function
rvn_apply_wyearly(rvn_hydrograph_data$hyd$Sub43_obs, rvn_which_max_xts)
#>                     Sub43_obs
#> 2003-09-30 04:00:00       103
#> 2004-09-30 04:00:00       258