Introduction

This is R code that will display a map of smoking habits in the UNited States

library(ggplot2)
library(dplyr)
library(tidyr)
library(DT)
library(maps)
 
## working directory = "~/Documents/Data Science/Kaggle/Maps/Smoking"
smoking <- read.csv("../data/tobacco.csv")

smoking$Smoke.everyday <- extract_numeric(smoking$Smoke.everyday)
smoking$Smoke.some.days <- extract_numeric(smoking$Smoke.some.days)
smoking$Former.smoker <- extract_numeric((smoking$Former.smoker))
smoking$Never.smoked <- extract_numeric(smoking$Never.smoked)
smoking$Year <- factor(smoking$Year)

smoking <- smoking[smoking$State!="district of columbia",]
smoking$State <- tolower(smoking$State)
all_states <- map_data("state")
smoking$region <- smoking$State
Total <- merge(all_states, smoking, by="region")

The Map

ggplot() +
  geom_polygon(data=Total, aes(x=long, y=lat, group = group, fill=Total$Smoke.everyday),colour="white") +
     scale_fill_continuous(low = "thistle2", high = "darkred", guide="colorbar") +
        labs(fill = "Every Day Smokers", title = "Statewise Every Day Smokers", x="", y="") +
          theme(legend.position = "top") +
        theme_bw() +
          scale_y_continuous(breaks=c()) + 
              scale_x_continuous(breaks=c()) + 
                  theme(panel.border =  element_blank()) +
                    theme(legend.position = "top")