| tspan | R Documentation |
tspan method determines the time span of time indices and time intervals.
tspan(x, ...)
## Default S3 method:
tspan(x, ...)
## S3 method for class 'tind'
tspan(x, na.rm = FALSE, ...)
## S3 method for class 'tinterval'
tspan(x, ...)
x |
an object of |
... |
further arguments passed to or from other methods. |
na.rm |
a logical value indicating whether missing values should be removed. |
Given tind argument, tspan returns a single tdiff
(or a single number for types "i" and "n") giving time span
of indices.
tspan for tinterval argument returns a tdiff of the same
length as the argument giving spans of time intervals.
Time spans are determined differently for time indices representing
periods of time (for example days) and for time indices that represent points
in time as determined by is.instant function. A sequence
of 3 consecutive dates has span of 3 days and a sequence of 5 consecutive
integers has span 5. On the other hand, a sequence of 3 consecutive hours
will have span of 2 hours, the difference between the last and the first hour,
see Examples.
A tdiff or a numeric vector (for integer and numeric indices).
tinterval class, is.instant function,
resolution_t method for determining the resolution of time indices,
is.regular method for checking if time indices form a regular
sequence.
# 4 consecutive days
(x <- today() + 0:3)
tspan(x)
# 10 consecutive integers
(x <- as.tind(1:10, "i"))
tspan(x)
# 4 consecutive hours
(x <- tind(H = 12:15))
# span is 3 hours (not 4)
tspan(x)
# the same
tind(H = 15) - tind(H = 12)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.