ts_plot: Time series decomposition and plot

Description Usage Arguments Value Examples

View source: R/ts_plot.R

Description

Convert a dataframe into a time series object, decompose it into trend, seasonality/cyclicity and noise/remainder/error and plot the raw data and the decomposed components. If the time series can't be decomposed, the function will just return the line chart of the raw data.

Usage

1

Arguments

data

dataframe: should be data.frame or tibble

col

str: the column to be analyzed

frequency

int: should choose from 1, 4, 12, 52

Value

ggplot Object

Examples

1
2
3
4
5
time <- c("1950 Q1", "1950 Q2", "1950 Q3", "1950 Q4",
          "1951 Q1", "1951 Q2", "1951 Q3", "1951 Q4")
earnings <- c(0.71, 0.63, 0.82, 0.91, 0.71, 0.63, 0.82, 0.91)
ts_data <- tibble::tibble(time, earnings)
ts_plot(data=ts_data, col="earnings", frequency=4)

UBC-MDS/ggexpress documentation built on March 29, 2020, 9:13 p.m.