find_eventDuration: Function to decompose a flow series into high flow events...

View source: R/find_eventDuration.R

find_eventDurationR Documentation

Function to decompose a flow series into high flow events defined as flows above a given threshold.

Description

This function accepts a vector of flow values, tests if each value in the flow vector is above or below a defined threshold, classifies the flow vector into events, and returns the average event duration or all event durations if average = FALSE. An event is defined as consecutive entries above the given threshold.

Usage

find_eventDuration(
  x,
  threshold,
  aggType = "average",
  type = "high",
  pref = "mean",
  trim = FALSE
)

Arguments

x

A vector of numeric flow values

threshold

Numeric threshold value for high flow events

aggType

Character vector indicating type of aggregation to use, if any. Choices are "average", "min", "max" or "none". If "average", mean or median of events is returned depending on "pref" setting If "none", returns the duration for each individual event

type

Character of either "high" or "low" indicating if events are defined as flows below or above the given threshold, respectively

pref

A character of either "mean" or "median", indicating whether to use mean or median. See details.

trim

Logical. Events that start or end at the beginning or end of the record are dropped if TRUE because an accurate duration can't be calculated if teh start or end time is unknown.

Value

A numeric of the mean event duration in units of number of rows if average = TRUE. Otherwise, returns a datafarme of durations for each event.

Examples

x <- sampleData$discharge
threshold <- median(x,na.rm=TRUE)
find_eventDuration(x,threshold)

USGS-R/EflowStats documentation built on Sept. 30, 2023, 9:31 p.m.