Learn R Programming

xts (version 0.14.1)

tformat: Get or Replace the Format of an xts Object's Index

Description

Generic functions to get or replace the format that determines how an xts object's index is printed.

Usage

tformat(x, ...)

tformat(x) <- value

indexFormat(x)

indexFormat(x) <- value

Value

A vector containing the format for the object's index.

Arguments

x

An xts object.

...

Arguments passed to other methods.

value

New index format string (see strptime() details for valid values).

Author

Jeffrey A. Ryan

Details

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.

See Also

index() has more information on the xts index, tclass() details how xts handles the class of the index, tzone() has more information about the index timezone settings.

Examples

Run this code

x <- timeBasedSeq('2010-01-01/2010-01-02 12:00')
x <- xts(seq_along(x), x)

# set a custom index format
head(x)
tformat(x) <- "%Y-%b-%d %H:%M:%OS3"
head(x)

Run the code above in your browser using DataLab