ts_long: Reshaping Multiple Time Series

Description Usage Arguments Value Examples

View source: R/ts_long_wide.R

Description

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.

Usage

1
2
3

Arguments

x

a ts-boxable time series, or a wide data.frame, data.table, or tibble.

Value

object with the same class as input

Examples

1
2
3
df.wide <- ts_wide(ts_df(ts_c(mdeaths, fdeaths)))
head(df.wide)
head(ts_long(df.wide))

Example output

        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

tsbox documentation built on April 30, 2020, 1:05 a.m.