Learn R Programming

tsbox (version 0.3.1)

ts_long: Reshaping Multiple Time Series

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

ts_long(x)

ts_wide(x)

Value

object with the same class as input

Arguments

x

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

Examples

Run this code
df.wide <- ts_wide(ts_df(ts_c(mdeaths, fdeaths)))
head(df.wide)
head(ts_long(df.wide))

Run the code above in your browser using DataLab