Skip to contents

Add many time series features to the data

Usage

tk_augment_timeseries_signature(.data, .date_var = NULL)

Arguments

.data

A time-based tibble or time-series object.

.date_var

For tibbles, a column containing either date or date-time values. If NULL, the time-based column will interpret from the object (tibble, xts, zoo, etc).

Value

Returns a tibble object describing the timeseries.

Details

tk_augment_timeseries_signature() adds 25+ time series features including:

  • Trend in Seconds Granularity: index.num

  • Yearly Seasonality: Year, Month, Quarter

  • Weekly Seasonality: Week of Month, Day of Month, Day of Week, and more

  • Daily Seasonality: Hour, Minute, Second

  • Weekly Cyclic Patterns: 2 weeks, 3 weeks, 4 weeks

See also

Augment Operations:

Underlying Function:

Examples

library(dplyr)

m4_daily %>%
    group_by(id) %>%
    tk_augment_timeseries_signature(date)
#> # A tibble: 9,743 × 31
#> # Groups:   id [4]
#>    id    date       value  index.num  diff  year year.iso  half quarter month
#>    <fct> <date>     <dbl>      <dbl> <dbl> <int>    <int> <int>   <int> <int>
#>  1 D10   2014-07-03 2076. 1404345600    NA  2014     2014     2       3     7
#>  2 D10   2014-07-04 2073. 1404432000 86400  2014     2014     2       3     7
#>  3 D10   2014-07-05 2049. 1404518400 86400  2014     2014     2       3     7
#>  4 D10   2014-07-06 2049. 1404604800 86400  2014     2014     2       3     7
#>  5 D10   2014-07-07 2006. 1404691200 86400  2014     2014     2       3     7
#>  6 D10   2014-07-08 2018. 1404777600 86400  2014     2014     2       3     7
#>  7 D10   2014-07-09 2019. 1404864000 86400  2014     2014     2       3     7
#>  8 D10   2014-07-10 2007. 1404950400 86400  2014     2014     2       3     7
#>  9 D10   2014-07-11 2010  1405036800 86400  2014     2014     2       3     7
#> 10 D10   2014-07-12 2002. 1405123200 86400  2014     2014     2       3     7
#> # ℹ 9,733 more rows
#> # ℹ 21 more variables: month.xts <int>, month.lbl <ord>, day <int>, hour <int>,
#> #   minute <int>, second <int>, hour12 <int>, am.pm <int>, wday <int>,
#> #   wday.xts <int>, wday.lbl <ord>, mday <int>, qday <int>, yday <int>,
#> #   mweek <int>, week <int>, week.iso <int>, week2 <int>, week3 <int>,
#> #   week4 <int>, mday7 <int>