Skip to contents

This function takes in a time-series object and returns it in a tibble format.

Usage

ts_to_tbl(.data)

Arguments

.data

The time-series object you want transformed into a tibble

Value

A tibble

Details

This function makes use of timetk::tk_tbl() under the hood to obtain the initial tibble object. After the inital object is obtained a new column called date_col is constructed from the index column using lubridate if an index column is returned.

Author

Steven P. Sanderson II, MPH

Examples


ts_to_tbl(BJsales)
#> # A tibble: 150 × 1
#>    value
#>    <dbl>
#>  1  200.
#>  2  200.
#>  3  199.
#>  4  199.
#>  5  199 
#>  6  200.
#>  7  199.
#>  8  200 
#>  9  200.
#> 10  201.
#> # ℹ 140 more rows
ts_to_tbl(AirPassengers)
#> # A tibble: 144 × 3
#>    index     date_col   value
#>    <yearmon> <date>     <dbl>
#>  1 Jan 1949  1949-01-01   112
#>  2 Feb 1949  1949-02-01   118
#>  3 Mar 1949  1949-03-01   132
#>  4 Apr 1949  1949-04-01   129
#>  5 May 1949  1949-05-01   121
#>  6 Jun 1949  1949-06-01   135
#>  7 Jul 1949  1949-07-01   148
#>  8 Aug 1949  1949-08-01   148
#>  9 Sep 1949  1949-09-01   136
#> 10 Oct 1949  1949-10-01   119
#> # ℹ 134 more rows