Generic functions to get or replace the format that determines how an xts object's index is printed.
tformat(x, ...)
tformat(x) <- value
indexFormat(x)
indexFormat(x) <- valueAn xts object.
Arguments passed to other methods.
New index format string (see strptime() details for valid
values).
A vector containing the format for the object's index.
Valid values for the value argument are the same as specified in the
Details section of strptime().
An xts object's tformat is NULL by default, so the index will be
be formatted according to its tclass() (e.g. Date, POSIXct, timeDate,
yearmon, etc.).
The tformat only changes how the index is printed and how the row names
are formatted when xts objects are converted to other classes (e.g. matrix
or data.frame). It does not affect the internal index in any way.
Both indexFormat() and indexFormat<- are deprecated in
favor of tformat() and tformat<-, respectively.
x <- timeBasedSeq('2010-01-01/2010-01-02 12:00')
x <- xts(seq_along(x), x)
# set a custom index format
head(x)
#> [,1]
#> 2010-01-01 00:00:00 1
#> 2010-01-01 00:01:00 2
#> 2010-01-01 00:02:00 3
#> 2010-01-01 00:03:00 4
#> 2010-01-01 00:04:00 5
#> 2010-01-01 00:05:00 6
tformat(x) <- "%Y-%b-%d %H:%M:%OS3"
head(x)
#> [,1]
#> 2010-Jan-01 00:00:00.000 1
#> 2010-Jan-01 00:01:00.000 2
#> 2010-Jan-01 00:02:00.000 3
#> 2010-Jan-01 00:03:00.000 4
#> 2010-Jan-01 00:04:00.000 5
#> 2010-Jan-01 00:05:00.000 6