calcStats {hydroEvents}R Documentation

Extract statistics from events

Description

Given the start and end indices of events statistics are calculated for the values in between the start and end points inclusive.

Usage

calcStats(srt, end, data, f.vec = c("which.max", "max", "min"))

Arguments

srt

Vector of indices for the event start

end

Vector of indices for the event end

data

Vector of data

f.vec

c("which.max", "max", "min") Functions to be applied to the events

Value

Returns a dataframe where the row is each event and the column is each statistic. If which.min or which.max are called the indices returned are global, that is, relative to the start of data.

See Also

eventPOT eventBaseflow eventMaxima eventMinima

Examples

# Extract event statistics and plot the maxima
event.indices = eventPOT(dataLoch, out.style = "none")
event.stats = calcStats(event.indices$srt, event.indices$end, dataLoch)
print(event.stats)

plot(1:length(dataLoch), dataLoch, type = "h", lwd = 2, col = "steelblue",
     ylab = "Rainfall (mm)", xlab = "Time index", mgp = c(2, 0.6, 0))
points(event.stats$which.max, event.stats$max, col = "red", pch = 16, cex = 1.2)
legend("topright", legend = c("Rainfall", "Max"), cex = 0.8,
       lwd = c(2, NA), pch = c(NA, 16), col = c("steelblue", "red"), bty = "n")

[Package hydroEvents version 0.11 Index]