Description Usage Arguments Value Examples
waterfallPlot() : a function that takes a dataframe and creates a waterfall plot as a ggplot2 object which can be further modified
1 2 |
df |
a dataframe with columns 'variable' (character), 'total' (numeric), 'base' (numeric), 'increase' (numeric), and 'decrease' (numeric). can have additional columns, ignored. Assumed to have starting value as first row and ending value as last row. |
palette |
default is c("#CC3300","#009900") #websafe red and green |
xlab |
title the x axis, default is "" |
ylab |
title the y axis, default is "" |
xfactors |
label the x axis; must equal the number of variables, default is df$variable |
offset |
which sets the width of the floating segments, default is "0.3" |
xtextangle |
changes the angle of text on the x axis, default is 90 |
a ggplot2 object
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | rrdf <- data.frame( # made up example
variable = c("Start","Factor 1","Factor 2","Factor 3","End"),
total = c(100, rep(NA, 3), 75),
base = c(NA, 75, 50, 50,NA),
increase = c(NA, 0, 0, 25, NA),
decrease = c(NA, 25, 25, 0, NA))
waterfallPlot(rrdf)
# With another color palette. Note that totals stay grey.
waterfallPlot(rrdf, palette=c("green","purple"))
# without intermediate tables, print the gross.permute plot
rawparamdf <- data.frame( # lighting example
params = c("ISR","deltaWatts","HOU","x"),
value = c(.5, 1.7, .2, 1.5),
stringsAsFactors = FALSE
)
waterfallPlot(waterfallPrep(rawparamdf, 200, .6, .8, output="gross"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.