title: "ggsupplyDemand"
author: "David Salazar"
date: "2018-05-19"
output:
html_document:
keep_md: true
ggsupplyDemand
is a package that makes it extremely easy to plot supply and demand systems with ggplot2
.
library(ggsupplyDemand)
create_supply_and_demand() %>%
shift_demand(outwards = TRUE) %>%
plot_supply_and_demand(consumer_surplus = TRUE)
ggsupplyDemand
wouldn't exist without Andrew Heiss from Brigham Young University and his post doing most of the heavylifting that ggsupplyDemand
leverages.
if (!require(devtools)) {
install.packages("devtools")
}
devtools::install_github("David-Salazar/ggsupplyDemand")
Build step-by-step a tibble
that represents a system of supply and demand. Use create_supply_and_demand()
and shift_demand()
, shift_supply()
.
create_supply_and_demand() %>%
shift_demand(outwards = TRUE) %>%
shift_supply(outwards = FALSE) %>%
plot_supply_and_demand(consumer_surplus = TRUE)
ggsupplyDemand
has a default shifter for both the demand and supply. However, if you need something different, you can always change it:
create_supply_and_demand() %>%
shift_supply() %>%
shift_supply(shifter = 250) %>%
shift_demand(outwards = FALSE, shifter = 400) %>%
plot_supply_and_demand()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.