#' Tornado Plot for Deterministic Sensitivity Analysis
#'
#' Creates a tornado plot from a data frame generated by [dsa_icer()].
#'
#' @param df A data frame from `dsa_icer()`.
#' @param metric Character string. Either "ICER" or "NMB". Must match the column name in `df`.
#'
#' @return A ggplot2 tornado-style line plot.
#' @export
#'
#' @examples
#' # Simulated deterministic sensitivity analysis result
#' dsa_result <- data.frame(
#' Parameter = c("Cost A", "Cost B", "Effect A"),
#' ICER = c(1000, 1200, 800),
#' NMB = c(20000, 19500, 21000)
#' )
#'
plot_tornado <- function(df, metric = "ICER") {
if (!(metric %in% names(df))) stop(paste("Column", metric, "not found in data"))
ggplot2::ggplot(df, ggplot2::aes_string(x = "Parameter", y = metric)) +
ggplot2::geom_line(color = "darkred", linewidth = 1) +
ggplot2::geom_point(color = "darkred") +
ggplot2::theme_minimal() +
ggplot2::labs(
title = paste("Tornado Plot -", metric),
x = "Parameter Value",
y = metric
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.