in_range {onlineforecast} | R Documentation |
Selects a period
Description
Returns a logical vector of boolean values where TRUE indicates if timestamp is within the specified period.
Usage
in_range(tstart, time, tend = NA)
Arguments
tstart |
The start of the period. |
time |
The timestamps as POSIX. |
tend |
The end of the period. If not given then the period will have no end. |
Details
Returns a logical vector of boolean values where TRUE indicates if timestamp is within the specified period spanned by tstart and tend.
Note the convention of time stamp in the end of the time intervals causes the time point
which equals tstart
not to be included. See last example.
The times can be given as character or POSIX, per default in tz='GMT'.
Value
A logical vector indicating the selected period with TRUE
Examples
# Take a subset
D <- subset(Dbuilding, c("2010-12-15", "2011-01-01"))
# Just a logical returning TRUE in a specified period
in_range("2010-12-20", D$t, "2010-12-22")
# Set which period to evaluate when optimizing parameters, like in rls_optim()
# (the points with scoreperiod == false are not included in the score evaluation)
D$scoreperiod <- in_range("2010-12-20", D$t)
D$scoreperiod
# Further, excluding a small period by
D$scoreperiod[in_range("2010-12-26", D$t, "2010-12-27")] <- FALSE
D$scoreperiod
# Note the convention of time stamp in the end of the time intervals
# causes the point with t = 2010-12-26 00:00:00 not to be included
# since it's covering to "2010-12-25 23:00:00" to "2010-12-26 00:00:00"
D$t[in_range("2010-12-26", D$t, "2010-12-27")]
# When characters are given, then they are translated to the time zone of the time vector
D <- subset(Dbuilding, c("2010-12-15", "2010-12-16"))
D$t <- ct(D$t, tz="CET")
D$t[in_range("2010-12-15 02:00", D$t, "2010-12-15 05:00")]
[Package onlineforecast version 1.0.2 Index]