TimeOfDaySubset: Subset by time-of-day

Description Usage Arguments Value Author(s) See Also Examples

View source: R/TimeOfDaySubset.R

Description

If the first time in the string is later in the day than the second time, the data between those times will be removed. Otherwise, x[timespan] will be returned.

Usage

1
  TimeOfDaySubset(x, timespan)

Arguments

x

xts data object

timespan

string (e.g. “T08:30/T15:00” or “"T17:00/T15:15"”)

Value

an extraction of the original xts object that includes either times betweeen the first and last time of timespan if the first time comes earlier in the day than the second, or times that are not between the last and first time if the the last time comes earlier in the day than the first time.

Author(s)

Garrett See

See Also

ExcludeTimes

Examples

1
2
3
4
5
6
x <- xts(1:10080, Sys.time() + 60 * 1:10080)
NROW(aggregate(x, format(index(x), "%H"), length)) # number of hours that have data
x1 <- TimeOfDaySubset(x, "T08:30/T14:59.999")
NROW(aggregate(x1, format(index(x1), "%H"), length))
x2 <- TimeOfDaySubset(x, "T18:00/T13:00.000")
NROW(aggregate(x2, format(index(x2), "%H"), length))

qmao documentation built on May 2, 2019, 4:54 p.m.