Markdown Presentation Data Product

Sayak

March 22, 2018

Develop Data Product - Assignment

library(plotly)
## Warning: package 'plotly' was built under R version 3.4.4
## Loading required package: ggplot2
## Warning: package 'ggplot2' was built under R version 3.4.4
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
library(fiftystater)
## Warning: package 'fiftystater' was built under R version 3.4.4
library(ggplot2)
myurl <- "https://www2.census.gov/govs/statetax/15staxcd.txt"
mydestfile <- "15staxcd.txt"
download.file(myurl, destfile = mydestfile) 

mydata <- read.table(mydestfile, header=TRUE, sep=",")
alcbev_taxes <- mydata[3,c(2:8, 10:52)] 

state_tax <- data.frame(State = names(alcbev_taxes), Taxes = t(alcbev_taxes))
names(state_tax)<-c("State", "Taxes") 

state_tax$hover <- with(state_tax, paste(State, '<br>', "Taxes:", Taxes)) 

# Make state borders white
borders <- list(color = toRGB("red"), width = 2)
# Set up some mapping options
map_options <- list(scope = 'usa',projection = list(type = 'albers usa'),
                    showlakes = TRUE, lakecolor = toRGB('white')
) 

Alcoholic Beverages Sales Tax per State, 2015

plot_ly(z = state_tax$Taxes, text = state_tax$hover, locations = state_tax$State, 
        type = 'choropleth', locationmode = 'USA-states', color = state_tax$Taxes, colors = 'Blues', marker = list(line = borders)) %>% 
  
  layout(title = 'Alcoholic Beverages Sales Tax per State, 2015 <br>(US Census Bureau)', geo = map_options)
## Warning: package 'bindrcpp' was built under R version 3.4.4