View source: R/graph_decompose.R
graph_decompose | R Documentation |
Function uses decompose
from the stats package to plot the series' observed values, seasonal,
trend, and irregular components using moving averages. User can set the seasonal component as additive or
multiplicative.
graph_decompose(
series_ts = NULL,
type_comp = "additive",
title = NULL,
x_title = NULL,
x_limits = NULL,
x_major_breaks = waiver(),
x_major_date_breaks = waiver(),
x_date_labels = waiver(),
col_width = 18,
row_height = 3.5,
display_plot = TRUE
)
series_ts |
A time series (class ts) object. |
type_comp |
A string that describes the type of seasonal component. Accepted values are "additive" and "multiplicative". |
title |
A string that defines an overall title to the multi-paneled plot. |
x_title |
A string that defines the x axis title. |
x_limits |
A Date/POSIXct 2 element vector that sets the minimum and maximum for the x axis. Use NA to refer to the existing minimum and maximum. |
x_major_breaks |
A Date/POSIXct vector or function that defines the exact major tic locations along the x axis. |
x_major_date_breaks |
For Date/POSIXct, a string containing the number and date unit for major breaks.
Examples: |
x_date_labels |
For Date/POSIXct, a string containing the format codes for the x axis date format.
This can be a strftime format for each x axis tic date label.
Examples: |
col_width |
An integer that sets the width of each plot column in centimeters. |
row_height |
An integer that sets the height of each plot column in centimeters. |
display_plot |
A logical that if TRUE displays the plot. |
Function uses the RplotterPkg::multi_panel_grid package to draw the multi-paneled plot.
if display_plot
is TRUE then the plots will be displayed. If display_plot
is FALSE then
the function returns a named list that includes a plot object which can be displayed from the console by entering:
grid::grid.newpage()
grid::grid.draw(plot object)
Returns a named list with:
"decompose_dt" – A data.frame and data.table with column values for the observed series, time, seasonal, trend, and random.
"plots" – A multi-paneled TableGrob object containing line plots of the
series' observed values, trend, seasonal, and random values across time.
Use grid::grid.draw(plots)
to display the plots.
Rick Dean
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.