isValidTimeSeries | R Documentation |
Test that Date or POSIXct date-time are unique, sorted and regular.
isValidTimeSeries(x, units = "hours", onError = warning)
x |
A vector of |
units |
Passed to |
onError |
A valid R function, such as |
Returns FALSE
if a problem was detected, and
TRUE
otherwise (unless onError
is stop
,
in which case an error is send and the function stops).
library( "macroutils2" )
timeseries <- seq.POSIXt(
from = as.POSIXct( "2015-01-01 12:00", tz = "GMT" ),
to = as.POSIXct( "2015-12-31 12:00", tz = "GMT" ),
by = "day"
)
isValidTimeSeries( x = timeseries )
# [1] TRUE
warning2 <- function(w){message("",w)}
# The time series is not increasing
tryCatch( isValidTimeSeries( x = rev( timeseries ) ),
warning = warning2 )
# The time series is not increasing homogeneously
tryCatch( isValidTimeSeries( x = timeseries[ -2 ] ),
warning = warning2 )
# The time series has duplicated values
timeseries2 <- rep( timeseries, each = 2 )
tryCatch( isValidTimeSeries( x = timeseries2 ),
warning = warning2 )
# See also option 'timeSeriesValid' in ?muPar
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.