tsbox is built around a set of converters, which convert time series
tibble to each
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
ts-boxable time series, an object of class
In data frames, multiple time series will be stored in a 'long' format. tsbox detects a value, a time and zero to several id columns. Column detection is done in the following order:
Starting on the right, the first first
integer column is
used as value column.
Using the remaining columns, and starting on the right again, the first
character column is used as time column.
character strings are parsed by
The time stamp,
time, indicates the beginning of a period.
All remaining columns are id columns. Each unique combination of id columns points to a time series.
Alternatively, the time column and the value column to be explicitly named as
value. If explicit names are used, the column order will be
Whenever possible, tsbox relies on heuristic time conversion. When a
"ts" time series, e.g.,
AirPassengers, is converted to a data
frame, each time stamp (of class
"Date") is the first day of the month. In
most circumstances, this reflects the actual meaning of the data stored in a
"ts" object. Technically, of course, this is not correct:
divide time in period of equal length, while in reality, February is shorter
than January. Heuristic conversion is done for frequencies of 0.1 (decades),
1 (years), 4 (quarters) and 12 (month).
For other frequencies, e.g. 260, of
EuStockMarkets, tsbox uses exact
time conversion. The year is divided into 260 equally long units, and time
stamp of a period will be a point in time (of class
ts-boxable time series of the desired class, an object of class
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
x.ts <- ts_c(mdeaths, fdeaths) head(x.ts) head(ts_df(x.ts)) suppressMessages(library(dplyr)) head(ts_tbl(x.ts)) suppressMessages(library(data.table)) head(ts_dt(x.ts)) suppressMessages(library(xts)) head(ts_xts(x.ts)) # heuristic time conversion # 1 momth: approx. 1/12 year head(ts_df(AirPassengers)) # exact time conversion # 1 trading day: exactly 1/260 year head(ts_df(EuStockMarkets)) # multiple id multi.id.df <- rbind( within(ts_df(ts_c(fdeaths, mdeaths)), type <- "level"), within(ts_pc(ts_df(ts_c(fdeaths, mdeaths))), type <- "pc") ) head(ts_ts(multi.id.df)) ts_plot(multi.id.df)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.