#' Plot Estimate Ridge Lines by Discrete Choice
#'
#' Visualizes the variance of an estimate conditional on a selected discrete choice.
#'
#' @param df The data frame as generated by \code{exhaust_design()}.
#' @param est A character value to indicate the variable in \code{df} that contains the pont estimate
#' that you want to plot.
#' @param dchoice A character value to indicate the discrete choice that you want to partition
#' your estimate ridgelines on.
#' @param hist Set to true if you want histogram ridges instead of densities. This is
#' more informative about the exact range of coefficient but does not look as nice.
#' Sets \code{stat = "binline"} in the \code{\link[ggridges]{geom_density_ridges}} call.
#' Experiment with parameter \code{scale < 1} to avoid overlapping histograms.
#' @param ... Additional parameters that are being passed on to \code{\link[ggridges]{geom_density_ridges}}
#' @return A \code{ggplot} object containing the plot.
#' @details See the vignette of the package for further details on how to implement the RDF workflow.
#' @examples
#' \dontrun{
#' print("Sorry. No examples yet.")
#' }
#' @export
plot_rdf_ridges_by_dchoice <- function(df, est, dchoice, hist = FALSE, ...) {
parms <- list(...)
if (hist) parms['stat'] <- "binline"
ggplot2::ggplot(df, ggplot2::aes_string(x = est, y = dchoice,
group = dchoice)) +
do.call(ggridges::geom_density_ridges, parms) +
ggridges::theme_ridges()
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.