wide.to.long {bsts} | R Documentation |
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.
WideToLong(response, na.rm = TRUE) LongToWide(response, series.id, timestamps)
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 |
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".
Steven L. Scott steve.the.bayesian@gmail.com
data(gdp) gdp.wide <- LongToWide(gdp$GDP, gdp$Country, gdp$Time) gdp.long <- WideToLong(gdp.wide)