Functions to reshape multiple time series from 'wide' to 'long' and vice
versa. Note that long format data frames are ts-boxable objects, where wide
format data frames are not. ts_long
automatically identifies a time
column, and uses columns on the left as id columns.
ts_long(x) ts_wide(x)
x | a ts-boxable time series, or a wide |
---|
object with the same class as input
#> time mdeaths fdeaths #> 1 1974-01-01 2134 901 #> 2 1974-02-01 1863 689 #> 3 1974-03-01 1877 827 #> 4 1974-04-01 1877 677 #> 5 1974-05-01 1492 522 #> 6 1974-06-01 1249 406#> id time value #> 1 mdeaths 1974-01-01 2134 #> 2 mdeaths 1974-02-01 1863 #> 3 mdeaths 1974-03-01 1877 #> 4 mdeaths 1974-04-01 1877 #> 5 mdeaths 1974-05-01 1492 #> 6 mdeaths 1974-06-01 1249