waterfallPlot: Makes a waterfall plot

Description Usage Arguments Value Examples

Description

waterfallPlot() : a function that takes a dataframe and creates a waterfall plot as a ggplot2 object which can be further modified

Usage

1
2
waterfallPlot(df, palette = c("#CC3300", "#009900"), xlab = "", ylab = "",
  xfactors = NULL, offset = 0.3, xtextangle = 90)

Arguments

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

Value

a ggplot2 object

Examples

 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"))

EMIjess/evalwaterfallr documentation built on May 6, 2019, 3:09 p.m.