findSpikes: Finds spikes in an obs data frame

View source: R/findSpikes.R

findSpikesR Documentation

Finds spikes in an obs data frame

Description

Finds spikes (short bursts of very large or small values) in the specified time variable. This uses the R base function diff to calculate the difference between the next (lead) and current value.

Usage

findSpikes(
  obs,
  colnum = 1,
  threshold = 0,
  spike_direction = "both",
  logfile = ""
)

Arguments

obs

Required. A CRHMr obs data frame.

colnum

Optional. The number of the column to test for spikes, not including the datetime.

threshold

Required. The threshold for the change in the observed values. The threshold is actually a rate, i.e. the change per unit time. So if you are looking at air temperature, and the threshold is set to 5, then any change in temperature of +/- 5 degrees in one time interval will be considered to be a spike.

spike_direction

string 'both' OR 'hi' OR 'low' to look at both high and low or hi or low spikes.

logfile

Optional. Name of the file to be used for logging the action. Normally not used.

Value

If successful and there are no spikes, returns 0. If there are spikes, returns their datetime values. If unsuccessful returns FALSE.

Note

If quiet=FALSE, the function displays a list of the datetimes of the spikes.

Author(s)

Kevin Shook, Alex Cebulski

See Also

deleteSpikes findGaps findDupes

Examples

# check for spikes in wind speed - look for changes greater than 10 m/s per interval
findSpikes(BadLake7376, 3, 10)

CentreForHydrology/CRHMr documentation built on April 6, 2024, 5:27 p.m.