knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

denverweed

The goal of denverweed is to provide a simple dataset for analysis which shows the different uses of wide/long form data, while giving insight into the trials and tribulations undergone by America’s favorite smokeable/tokeable 5-to-13 leafletted plant

Installation

The development version of denverweed is available from GitHub with:

install.packages("devtools")
devtools::install_github("Reed-Math241/denverweed")

About the data

The data were collected and made available by the City of Denver Open Data Catalog.

the denverweed package contains two datasets.

library(pkgGrpm)
data(package = 'pkgGrpm')

It contains the dataset weed, which contains 4 variables and 90 observations:

head(weed)

It also contains weed_wider, a pivoted, untidy version of weed which may be useful for certain graphs, containing 4 variables and 45 rows

head(weed_wider)

Example

of course, we're curious to see how marijuana sales have changed over the years. here we plot gross sales by year, faceted by medical or retail

library(tidyverse)
ggplot(weed, aes(x = YEAR, y = GROSS_SALES)) + 
  geom_bar(stat = 'identity', fill = '#709B40') +
  facet_wrap(~GROSS_SALES_TYPE) +
  scale_y_continuous(labels = scales::comma) + 
  ylab("Gross Sales ($)") + 
  xlab("Year")+
  theme_bw()

if we plot sales by month, we can add more detail. here we plot gross sales by month, faceted by year. we can see a general increase in marijuana sales.

ggplot(weed, aes(x = MONTH, y = GROSS_SALES)) + 
  geom_bar(stat = 'identity', fill = '#709B40') +
  facet_wrap(~YEAR) +
  scale_y_continuous(labels = scales::comma) +
  ylab("Gross Sales ($)") + 
  xlab("Month") +
  theme_bw()+
  theme(axis.text.x = element_text(angle = 90))

now we'd like to see the difference in medical/retail sales over time, by month. here we plot gross sales by month, faceted by year and retail/medical

ggplot(weed, aes(x = MONTH, y = GROSS_SALES)) + 
  geom_bar(stat = 'identity', fill = '#709B40') +
  facet_grid(GROSS_SALES_TYPE ~ YEAR) +
  scale_y_continuous(labels = scales::comma) + 
  ylab("Gross Sales ($)") + 
  xlab("Month") +
  theme_bw()+
  theme(axis.text.x = element_text(angle = 90))

finally, a use for weed_wider in a scatterplot of medical vs retail sales, by year

ggplot(weed_wider, aes(x = `Medical Total Gross Sales`, y = `Retail Total Gross Sales`, color = YEAR)) +
  geom_point() +
  scale_y_continuous(labels = scales::comma) +
  scale_x_continuous(labels = scales::comma) +
  scale_color_discrete(name = "Year") +
  theme_bw()

Attribution

The data “Marijuana Gross Sales” ver 1.0.733, from the City of Denver Open Data Catalog, is licensed under CC BY 3.0

License

Data are available under a CC BY 3.0 license, in accordance with the City of Denver Open Data Catalog terms of use



Reed-Math241/denverweed documentation built on Dec. 18, 2021, 9:56 a.m.