-
Notifications
You must be signed in to change notification settings - Fork 25
/
format.timestamps.Rd
executable file
·74 lines (56 loc) · 2.08 KB
/
format.timestamps.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
\name{format.timestamps}
\alias{NoDuplicates}
\alias{NoGaps}
\alias{IsRegular}
\alias{HasDuplicateTimestamps}
\title{Checking for Regularity}
\Rdversion{1.0}
\description{
Tools for checking if a series of timestamps is 'regular' meaning that
it has no duplicates, and no gaps. Checking for regularity can be
tricky. For example, if you have monthly observations with
\code{\link{Date}} or \code{\link{POSIXt}} timestamps then gaps
between timestamps can be 28, 29, 30, or 31 days, but the series is
still "regular".
}
\usage{
NoDuplicates(timestamps)
NoGaps(timestamps)
IsRegular(timestamps)
HasDuplicateTimestamps(bsts.object)
}
\arguments{
\item{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 \code{\link{Date}} object, or a
\code{\link{POSIXt}} object.}
\item{bsts.object}{A bsts model object.}
}
\value{
All four functions return scalar logical values. \code{NoDuplicates}
returns \code{TRUE} if all elements of \code{timestamps} are unique.
\code{NoGaps} examines the smallest nonzero gap between time points.
As long as no gaps between time points are more than twice as wide as
the smallest gap, it returns \code{TRUE}, indicating that there are no
missing timestamps. Otherwise it returns \code{FALSE}.
\code{IsRegular} returns \code{TRUE} if \code{NoDuplicates} and
\code{NoGaps} both return \code{TRUE}.
\code{HasDuplicateTimestamps} returns \code{FALSE} if the data used to
fit bsts.model either has NULL timestamps, or if the timestamps
contain no duplicate values.
}
\author{
Steven L. Scott \email{[email protected]}
}
\examples{
first <- as.POSIXct("2015-04-19 08:00:04")
monthly <- seq(from = first, length.out = 24, by = "month")
IsRegular(monthly) ## TRUE
skip.one <- monthly[-8]
IsRegular(skip.one) ## FALSE
has.duplicates <- monthly
has.duplicates[1] <- has.duplicates[2]
IsRegular(has.duplicates) ## FALSE
}
\keyword{chron}