graph_dif | R Documentation |
The lagged differences across a time series at a certain degree dif_lag
is taken primarily to transform the series from a non-stationary to stationary process.
Function returns a multi-paneled plot of the observed time series (optional), along with a
plot for the series' lagged differences. The actual difference values are also returned
in a data.frame.
graph_dif(
df = NULL,
time_col = NULL,
value_col = NULL,
dif_lag = 1,
title = NULL,
x_title = NULL,
y_title = NULL,
x_limits = NULL,
x_major_breaks = waiver(),
x_major_date_breaks = waiver(),
x_date_labels = waiver(),
y_limits = NULL,
y_major_breaks = waiver(),
show_pts = TRUE,
show_obs = TRUE,
show_major_grids = TRUE,
show_minor_grids = TRUE,
col_width = 18,
row_height = 5,
display_plot = TRUE,
png_file_path = NULL
)
df |
A data.frame containing a time series with both a value and time column. |
time_col |
Names the column from |
value_col |
Names the numeric column from |
dif_lag |
An integer that sets the lag of difference to use. |
title |
A string that defines an overall title to the pair of plots. |
x_title |
A string that sets the x axis title. |
y_title |
A string that sets the y 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: |
y_limits |
A numeric 2 element vector that sets the minimum and maximum for the difference y axis. Use NA to refer to the existing minimum and maximum. |
y_major_breaks |
A numeric vector or function that defines the exact major tic locations for the difference y axis'. |
show_pts |
A logical which if FALSE will plot only the lines. |
show_obs |
A logical which if FALSE hides the plot of observations. |
show_major_grids |
A logical that controls the appearance of major grids. |
show_minor_grids |
A logical that controls the appearance of minor grids. |
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. |
png_file_path |
A character string with the directory and file name to produce a png image of the plot. |
The 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)
Returning a named list with:
"diff_df" – A data frame with column variables for time "DateTime" and the difference values "Value".
"plots" – A multi-paneled TableGrob object plotting the differences and optionally
the observed series. 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.