regularize.timestamps function

Produce a Regular Series of Time Stamps

Produce a Regular Series of Time Stamps

Given an set of timestamps that might contain duplicates and gaps, produce a set of timestamps that has no duplicates and no gaps.

1.0

RegularizeTimestamps(timestamps) ## Default S3 method: RegularizeTimestamps(timestamps) ## S3 method for class 'numeric' RegularizeTimestamps(timestamps) ## S3 method for class 'Date' RegularizeTimestamps(timestamps) ## S3 method for class 'POSIXt' RegularizeTimestamps(timestamps)

Arguments

  • timestamps: A set of (possibly irregular or non-unique) timestamps. This could be a set of integers (like 1, 2, , 3...), a set of numeric like (1945, 1945.083, 1945.167, ...) indicating years and fractions of years, a Date object, or a POSIXt object.

If the argument is

NULL

a

NULL

will be returned.

Returns

A set of regularly spaced timestamps of the same class as the argument (which might be NULL).

Author(s)

Steven L. Scott steve.the.bayesian@gmail.com

Examples

first <- as.POSIXct("2015-04-19 08:00:04") monthly <- seq(from = first, length.out = 24, by = "month") skip.one <- monthly[-8] has.duplicates <- monthly has.duplicates[2] <- has.duplicates[3] reg1 <- RegularizeTimestamps(skip.one) all.equal(reg1, monthly) ## TRUE reg2 <- RegularizeTimestamps(has.duplicates) all.equal(reg2, monthly) ## TRUE
  • Maintainer: Steven L. Scott
  • License: LGPL-2.1 | MIT + file LICENSE
  • Last published: 2024-01-17

Useful links