#' Produces a plot of a time series statistics,
#' where the statistics are some dollar value.
#' @param ms the model statistic as an XTS value history, one
#' or more such columns
#' @param title the plot title
#' @param y_label the plot's Y-axis label, default
#' \code{Value ($)}.
#' @param line_color the color for the value line,
#' default \code{blue}.
#' @return a \code{ggplot2} plot object for further manipulation
#' @note Removes the X-axis label in favor of time series dates
plot_model_stat <- function(ms,
title,
y_label = "Value ($)",
line_color = "blue") {
Date <- Value <- NULL
df <- data.frame(zoo::coredata(ms), zoo::index(ms))
colnames(df) <- c("Value", "Date")
g <-
ggplot2::ggplot(df, ggplot2::aes(x = Date,
y = Value)) +
ggplot2::geom_line(color = line_color) +
ggplot2::xlab(NULL) +
ggplot2::scale_y_continuous(name = y_label,
labels = scales::dollar) +
ggplot2::ggtitle(title)
g
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.