plot_waterfall: Make a waterfall plot from a tibble of cash flows

Description Usage Arguments Value Examples

View source: R/waterfall.R

Description

The only requirement for this function to work is that the first row and last row of the tibble represent the cash in and cash out. In other words the Base and the Total when talking about sales modeling.

Usage

1

Arguments

data

the data tibble to operate on

Value

a ggplot of the waterfall plot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
library(ggplot2)
datadf <-
  tibble::tibble(
    desc = c(
      "starting_net_income",
      "write_offs",
      "sales",
      "COGS",
      "overhead",
      "taxes",
      "bonuses",
      "other_income",
      "ending_net_income"
    ),
    amount = c(1200, -2300, 11000, -9000, -1900, -1200, -3000, 7000, 1800)
  )
plot_waterfall(datadf) +
  scale_fill_brewer(type = "seq", palette = 4) +
  theme(axis.text.x = element_text(angle = 90, vjust = 0.9, hjust = 1))

DoktorMike/datools documentation built on Feb. 28, 2021, 8:39 a.m.