#Demographic Data
TexasCountyData <- read.csv("Texas.csv")
head(TexasCountyData)
##   FIPS County County.Name Total Anglo Black Hispanic Other
## 1    1      1    Anderson 58458 36064 12489     9287   618
## 2    3      2     Andrews 14786  7164   226     7195   201
## 3    5      3    Angelina 86771 55230 13197    17145  1199
## 4    7      4     Aransas 23158 16543   296     5690   629
## 5    9      5      Archer  9054  8255    39      675    85
## 6   11      6   Armstrong  1901  1742    11      124    24
#US Coordinates
USA <- map_data("county")

#Texas coordinates only
TexasCounties <- USA[which(USA$region=="texas"),]
head(TexasCounties)
##            long      lat group order region subregion
## 74520 -95.75271 31.53560  2492 74520  texas  anderson
## 74521 -95.76989 31.55852  2492 74521  texas  anderson
## 74522 -95.76416 31.58143  2492 74522  texas  anderson
## 74523 -95.72979 31.58143  2492 74523  texas  anderson
## 74524 -95.74698 31.61008  2492 74524  texas  anderson
## 74525 -95.72405 31.63873  2492 74525  texas  anderson
#Data Cleaining
colnames(TexasCountyData)[3] <- "subregion"
TexasCountyData$subregion <- tolower(TexasCountyData$subregion)

#Combining the datasets by county
Combined <- inner_join(TexasCounties,TexasCountyData,by="subregion")
attach(Combined)
theme_update(plot.title = element_text(hjust = 0.5))
Base <- ggplot()

#Hispanic Map
HispanicPercentage <- Base + geom_polygon(data = Combined, aes(x=long, y = lat, group = group,fill=Hispanic/Total),color="black") + theme_void() + coord_map() + scale_fill_gradientn(colours =rev(rainbow(4))) + ggtitle("Percent Hispanic by County")
HispanicPercentage

#Anglo Map
AngloPercentage <- Base + geom_polygon(data = Combined, aes(x=long, y = lat, group = group,fill=Anglo/Total),color="black") + theme_void() + coord_map() + scale_fill_gradientn(colours =rev(rainbow(4))) + ggtitle("Percent White by County")
AngloPercentage

#Black Map
BlackPercentage <- Base + geom_polygon(data = Combined, aes(x=long, y = lat, group = group,fill=Black/Total),color="black") + theme_void() + coord_map() + scale_fill_gradientn(colours =rev(rainbow(4))) + ggtitle("Percent Black by County")
BlackPercentage