Learn R Programming

xts (version 0.13.2)

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

# S3 method for xts tformat(x, ...) # S3 method for xts tformat(x) <- value

##### The functions below are DEPRECATED ##### indexFormat(x) indexFormat(x) <- value

Value

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

Arguments

x

an xts object

value

new index format string (see Details for valid values)

...

arguments passed to other methods

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 formatted according to its tclass (e.g. Date, POSIXct, timeDate, yearmon, etc.).

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