ts_table: Create ts_table

View source: R/functions.R

ts_tableR Documentation

Create ts_table

Description

Create a ts_table.

Usage

ts_table(data, timestamp, columns)

Arguments

data

numeric

timestamp

Date or POSIXct

columns

column names

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’).

Value

a ts_table

Author(s)

Enrico Schumann

See Also

as.ts_table

Examples

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

tsdb documentation built on March 7, 2023, 7:31 p.m.

Related to ts_table in tsdb...