Maximum number of consecutive entries with respect to threshold
maxRunningValue.Rd
Compute the maximum number of consecutive entries above, equal or lower
than a given threshold
.
Arguments
- obs
a numeric vector of data to be compared the the threshold.
- threshold
a double numeric value for comparison.
- logic
a character vector which con only be 'greater' (default), 'equal' or 'lower'.
Details
The function computes the maximum number of consecutive elements of a list of number
above, equal or lower than a given threshold.
Its behaviour is regulated by the value of the logic
argument.
Examples
if (FALSE) {
# `modeldata` is a `data.table` with columns: datetime, no2, x and y.
# Let's look for the maximum number of consecutive days with no2 > 200, cell by cell.
modeldata[, heavyPoll := maxRunningValue(no2, threshold = 200), by = list(x, y)]
}