Learn R Programming

tsdb (version 1.1-0)

ts_table: Create ts_table

Description

Create a ts_table.

Usage

ts_table(data, timestamp, columns)

Value

a ts_table

Arguments

data

numeric

timestamp

Date or POSIXct

columns

column names

Author

Enrico Schumann

Details

Create a time-series table (ts_table). A ts_table is a numeric matrix, so there is always a dim attribute. For a ts_table x, you get the number of observations with dim(x)[1L].

Attached to this matrix are several attributes:

timestamp

a vector: the numeric representation of the timestamp

t.type

character: the class of the original timestamp, either Date or POSIXct

columns

a character vector that provides the columns names

There may be other attributes as well, but these three are always present.

Timestamps must be of class Date or POSIXct (POSIXlt is converted). A tzone attribute is dropped.

A ts_table is not meant as a time-series class. For most computations (plotting, calculation of statistics, etc.), the ts_table must first be coerced to zoo, xts, a data.frame or a similar data structure. Methods that perform such coercions are responsible for converting the numeric timestamp vector to an actual timestamp. For this, they may use the function ttime (‘translate time’).

See Also

as.ts_table

Examples

Run this code
ts_table(1:5, Sys.Date() - 5:1, columns = "value")

Run the code above in your browser using DataLab