This function creates a "tornado" plot using the ggplot2 package. These are primarily used to display results of a sensitivity analysis.
ggtornado(data, baseline, var, level, value, result)
A data frame containing the results of a sensitivity analysis.
The baseline value for the sensitivity analysis.
The data column identifying the variable name being varied.
The data column identifying the sensitivity case level (usually 'high' or 'low', relative to the baseline).
The data column identifying the value of the variable being varied.
The data column identifying the result when the variable 'var' is set at the value of 'value'.
# Create an example data frame of a sensitivity analysis - columns:
# 'var' <- The name of the variable being varied.
# 'level' <- 'high' or 'low' (relative to the baseline).
# 'value' <- The value of the variable being varied.
# 'result' <- The result of the output value at the varied variable value.
data <- data.frame(
var = c('price', 'price', 'fuelEconomy', 'fuelEconomy',
'accelTime', 'accelTime'),
level = rep(c('high', 'low'), 3),
value = c(10, 20, 25, 15, 10, 6),
result = c(0.95, 0.15, 0.90, 0.60, 0.85, 0.75)
)
# Make a tornado plot of the sensitivity analysis results:
library(ggplot2)
ggtornado(
data = data,
baseline = 0.8, # Baseline result
var = 'var',
level = 'level',
value = 'value',
result = 'result'
)