powered by
Decomposes a time series into trend, seasonal, and residual components using simple moving averages and group means. The function returns the residual component (or the original series with trend removed) to simplify analysis.
decompose_ts(data, cols = NULL, date_col = NULL, period = "month", method = "additive", verbose = FALSE)
A data frame with the residual component.
A data frame with a time column.
Column indices or names to decompose.
Time column index or name.
Seasonal period: "month", "day", or "hour".
"month"
"day"
"hour"
Decomposition method: "additive" or "multiplicative".
"additive"
"multiplicative"
Logical; if TRUE, prints progress message.
TRUE
decompose_ts(data[1:500, c(1, 4, 17:19)], cols = 3:5, date_col = 1, period = "month")
Run the code above in your browser using DataLab