View source: R/find_eventDuration.R
find_eventDuration | R Documentation |
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.
find_eventDuration(
x,
threshold,
aggType = "average",
type = "high",
pref = "mean",
trim = FALSE
)
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 |
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.
x <- sampleData$discharge
threshold <- median(x,na.rm=TRUE)
find_eventDuration(x,threshold)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.