tk_get_timeseries: Get summary attributes from a time-series index

Description Usage Arguments Details Value See Also Examples

Description

Get summary attributes from a time-series index

Usage

1
2
3

Arguments

idx

A time-series index that is a vector of dates or datetimes.

Details

tk_get_timeseries_signature decomposes the timeseries into commonly needed features such as numeric value, differences, year, month, day, day of week, day of month, day of year, hour, minute, second.

tk_get_timeseries_summary returns the summary returns the start, end, units, scale, and a "summary" of the timeseries differences in seconds including the minmum, 1st quartile, median, mean, 3rd quartile, and maximum frequency. The timeseries differences give the user a better picture of the index frequency so the user can understand the level of regularity or irregulairity. A perfectly regular time series will have equal values in seconds for each metric. However, this is not often the case.

Important Note: These functions only work with time-based indexes in datetime, date, yearmon, and yearqtr values. Regularized dates cannot be decomposed.

Value

Returns a tibble object describing the timeseries.

See Also

tk_index(), tk_augment_timeseries_signature(), tk_make_future_timeseries()

Examples

 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
library(tidyquant)
library(timekit)

# Works with time-based tibbles
FB_tbl <- FANG %>% filter(symbol == "FB")
FB_idx <- tk_index(FB_tbl)

tk_get_timeseries_signature(FB_idx)
tk_get_timeseries_summary(FB_idx)


# Works with dates in any periodicity
idx_weekly <- seq.Date(from = ymd("2016-01-01"), by = 'week', length.out = 6)

tk_get_timeseries_signature(idx_weekly)
tk_get_timeseries_summary(idx_weekly)


# Works with zoo yearmon and yearqtr classes
idx_yearmon <- seq.Date(from       = ymd("2016-01-01"),
                        by         = "month",
                        length.out = 12) %>%
    as.yearmon()

tk_get_timeseries_signature(idx_yearmon)
tk_get_timeseries_summary(idx_yearmon)

timekit documentation built on July 4, 2017, 9:45 a.m.