deleteSpikes: Deletes spikes in an obs data frame

View source: R/deleteSpikes.R

deleteSpikesR Documentation

Deletes spikes in an obs data frame

Description

Finds spikes, and sets their values to be NA_real_.

Usage

deleteSpikes(
  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

One of hi (high spikes), low (low spikes) or both (the default).

logfile

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

Value

If successful, returns a data frame consiting of the datetime and the original obs values, where all of the spike values have been set to be NA_real_. If no spikes are found a message is printed and the fucntion returns the value FALSE.

Author(s)

Kevin Shook Alex Cebulski

See Also

findSpikes

Examples

BadLake <- BadLake7376
# finds all windspeeds which change by more than 10 m/s per interval,
# and sets their values to NA_real_
BadLake$u.nospikes <- deleteSpikes(BadLake7376, 3, 10)

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