wide.to.long {bsts} | R Documentation |
Convert Between Wide and Long Format
Description
Convert a multivariate time series between wide and long formats. In "wide" format there is one row per time point, with series organzied by columns. In "long" format there is one row per observation, with variables indicating the series and time point to which an observation belongs.
Usage
WideToLong(response, na.rm = TRUE)
LongToWide(response, series.id, timestamps)
Arguments
response |
For For |
na.rm |
If TRUE then missing values will be omitted from the returned data frame (their absence denoting missingness). Otherwise, missing values will be included as NA's. |
series.id |
A factor (or variable coercible to factor) of the
same length as |
timestamps |
A variable of the same length as |
Value
LongToWide
returns a zoo matrix with the time series in wide format.
WideToLong
returns a 3-column data frame with columns "time", "series", and "values".
Author(s)
Steven L. Scott steve.the.bayesian@gmail.com
Examples
data(gdp)
gdp.wide <- LongToWide(gdp$GDP, gdp$Country, gdp$Time)
gdp.long <- WideToLong(gdp.wide)