deDupe: Removes duplicated datetimes in obs data frame

View source: R/deDupe.R

deDupeR Documentation

Removes duplicated datetimes in obs data frame

Description

Removes duplicated datetime values. Many time series, especially from Environment Canada, may contain duplicated datetimes. This function replaces the duplicated values. It is important to use this function before interpolating or imputing values, and especially before writing the data frame to an obs file.

Usage

deDupe(obs, action = "mean", quiet = TRUE, logfile = "")

Arguments

obs

Required. A CRHMr data frame containing the obs values.

action

Optional. The action used to replace the duplicate values. Must be one of min, max, mean, skip, delete, split or second. Default is mean.

quiet

Optional. Suppresses display of messages, except for errors. If you are calling this function in an R script, you will usually leave quiet=TRUE (i.e. the default). If you are working interactively, you will probably want to set quiet=FALSE.

logfile

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

Value

If there are no duplicates, returns 'No duplicates'. If duplicates exist, and are are successfully removed, the de-duplicated data frame is returned. If the de-duplication is unsuccessful, then an error is returned.

Note

If action=min, max, or mean, the action function is applied to all of the values for each duplicate datetime. If action=skip or delete, then the values of the duplicate datetimes are deleted. If action=split then the original values are kept, and the duplicate values are written to an obs file. The name of the obs file is the name of the obs variable followed by '_dupes.obs'. If action=second, then the second duplicate values are used. This can be useful when dealing with duplicates caused by daylight savings time.

Author(s)

Kevin Shook

See Also

findDupes

Examples

BadLake.deduped <- deDupe(BadLake7376, action='mean')

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