Skip to contents

Utility function to extract user-defined run lengths (durations) above a threshold

Usage

selectRunning(
  mydata,
  pollutant = "nox",
  criterion = ">",
  run.len = 5,
  threshold = 500,
  result = c("yes", "no")
)

Arguments

mydata

A data frame with a date field and at least one numeric pollutant field to analyse.

pollutant

Name of variable to process. Mandatory.

criterion

Condition to select run lengths e.g. ">" with select data more than threshold.

run.len

Run length for extracting contiguous values of pollutant above the threshold value.

threshold

The threshold value for pollutant above which data should be extracted.

result

A new column criterion is returned with string to identity whether condition was met.

Value

Returns a data frame that meets the chosen criteria. See examples below.

Details

This is a utility function to extract runs of values above a certain threshold. For example, for a data frame of hourly NOx values we would like to extract all those hours where the concentration is at least 500ppb for contiguous periods of 5 or more hours.

This function is useful, for example, for selecting pollution episodes from a data frame i.e. where concentrations remain elevated for a certain period of time. It may also be of more general use when analysing air pollution data. For example, selectRunning could be used to extract continuous periods of rainfall — which could be important for particle concentrations.

Author

David Carslaw

Examples


## extract those hours where there are at least 5 consecutive NOx
## concentrations above 500ppb

mydata <- selectRunning(mydata, run.len = 5, threshold = 500)

## make a polar plot of those conditions...shows that those
## conditions are dominated by low wind speeds, not
## in-canyon recirculation
if (FALSE) polarPlot(mydata, pollutant = "nox", type = "criterion") # \dontrun{}