library(maps)
library(ggplot2)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
#View(USArrests)
arrests=USArrests
arrests$region=tolower(rownames(USArrests))
#retrieving the states
state_map=map_data("state")
arrest_map=left_join(x=state_map,y=arrests,by="region")
#View(arrest_map)

#high to low
ggplot(data=arrest_map,aes(x=long,y=lat,group=group))+geom_polygon(aes(fill=Assault),col="white")+scale_fill_viridis_c(option = 'A',direction=-1) + labs(x="Longitude", y="Latitude", title="Assault-high_to_low - 21MIC0065")

ggplot(data=arrest_map,aes(x=long,y=lat,group=group))+geom_polygon(aes(fill=Murder),col="blue")+scale_fill_viridis_c(option = 'B',direction=-1)+ labs(x="Longitude", y="Latitude", title="Murder-high_to_low - 21MIC0065")

ggplot(data=arrest_map,aes(x=long,y=lat,group=group))+geom_polygon(aes(fill=Rape),col="red")+scale_fill_viridis_c(option = 'C',direction=-1)+ labs(x="Longitude", y="Latitude", title="Rape-high_to_low - 21MIC0065")

arrest_map$total<- c(arrest_map$Murder + arrest_map$Assault + arrest_map$Rape)
ggplot(data=arrest_map,aes(x=long,y=lat,group=group))+geom_polygon(aes(fill=total),col="yellow")+scale_fill_viridis_c(option = 'E',direction=-1)+ labs(x="Longitude", y="Latitude", title="Total cases-high_to_low - 21MIC0065")

#low to high
ggplot(data=arrest_map,aes(x=long,y=lat,group=group))+geom_polygon(aes(fill=Assault),col="white")+scale_fill_viridis_c(option = 'A',direction=1)+ labs(x="Longitude", y="Latitude", title="Assault-low_to_high - 21MIC0065")

ggplot(data=arrest_map,aes(x=long,y=lat,group=group))+geom_polygon(aes(fill=Murder),col="blue")+scale_fill_viridis_c(option = 'B',direction=1)+ labs(x="Longitude", y="Latitude", title="Murder-low_to_high - 21MIC0065")

ggplot(data=arrest_map,aes(x=long,y=lat,group=group))+geom_polygon(aes(fill=Rape),col="red")+scale_fill_viridis_c(option = 'C',direction=1)+ labs(x="Longitude", y="Latitude", title="Rape-low_to_high - 21MIC0065")

ggplot(data=arrest_map,aes(x=long,y=lat,group=group))+geom_polygon(aes(fill=total),col="yellow")+scale_fill_viridis_c(option = 'E',direction=1)+ labs(x="Longitude", y="Latitude", title="Total cases-low_to_high - 21MIC0065")