| tind | R Documentation |
tind is an S3 class representing time indices of different
types (years, quarters, months, ISO 8601 weeks, dates, date-time,
and arbitrary integer/numeric indices). Time indices are represented
by vectors of integers or doubles with type attribute and
time zone attribute (date-time only). Objects of tind behave like plain
vectors and can be easily used in data frames.
A tind object would usually be created using as.tind
method or using parse_t and strptind functions.
tind constructor allows to create time indices from components
(like year, month, day) and to create vectors of a given length
filled with NA values.
is.tind function checks whether an object is of tind class.
tind(..., length = 0L, type = NULL, tz = NULL)
is.tind(x)
... |
components of time index to be constructed (in arbitrary order), the following are accepted:
|
length |
an integer value specifying the desired length. |
type |
a character value determining time index type
( |
tz |
(optional) a character value determining the time zone (the default
|
x |
any R object. |
tind class supports the following types of time indices:
internal code "y".
internal code "q".
internal code "m".
internal code "w".
internal code "d".
internal code "t".
internal code "h".
"i".
"n".
Valid ranges for time indices are:
"y")0000–9999.
"q")0000q1–9999q4.
"m")0000-01–9999-12.
"w")0000-W01–9999-W52.
"d")0000-01-01–9999-12-31.
"t")from 0000-01-01 15:00:00Z to 9999-12-31 09:00:00Z
(between -62167165200 and 253402246800
seconds since the Unix epoch).
"h")from 00:00 to 24:00
(between 0 and 86400 seconds since midnight).
An object of tind class for tind or a logical
value for is.tind.
as.tind for conversion to tind,
parse_t and strptind functions for
parsing character strings, date_time for construction
of date-time indices from date and time components, tind-methods
for basic methods.
# years
tind(y = 2010:2020)
tind(type = "y")
tind(length = 11, type = "y")
# quarters
tind(y = rep(2020:2023, each = 4), q = 1:4)
tind(q = 1:4, y = rep(2020:2023, each = 4))
tind(type = "q")
tind(length = 4, type = "q")
# months
tind(y = 2023, m = 1:12)
tind(m = 1:12, y = 2023)
tind(type = "m")
tind(length = 12, type = "m")
# weeks
tind(y = 2024, w = 1 + 2 * (0:25))
tind(type = "w")
tind(length = 13, type = "w")
# dates
tind(m = 3, d = 15, y = 2024)
tind(y = 2024, m = rep(1:3, each = 2), d = c(1, 15))
tind(type = "d")
tind(length = 6, type = "d")
# time of day
tind(H = 16, M = (0:3) * 15)
tind(type = "h")
tind(length = 4, type = "h")
# date-time
# system time zone
tind(y = 2024, m = 8, d = 2, H = 16, M = (0:3) * 15)
tind(y = 2024, m = 8, d = 2, H = 16, M = (0:3) * 15)
tind(y = 2024, m = 8, d = 2, H = 16, M = 0, S = 10 * (0:5))
# time zone explicitly provided
tind(y = 2024, m = 8, d = 2, H = 16, M = (0:3) * 15, tz = "UTC")
tind(type = "t")
tind(type = "t", tz = "UTC")
tind(length = 4, type = "t")
tind(length = 4, type = "t", tz = "UTC")
# integer and numeric indices
# (cannot be constructed from components like above)
tind(length = 10, type = "i")
tind(length = 10, type = "n")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.