In: Computer Science
How do I create a choropleth map of the United States where there are two maps. One that shows the states and one that shows the counties, in Rstudio, from the beginning. When I hover a state or county the border should be highlighted and the name of the state/county displayed.
I need to do this so that I can display the COVID-19 data that I have.
How do I create a choropleth map of the United States where there are two maps. One that shows the states and one that shows the counties, in Rstudio, from the beginning. When I hover a state or county the border should be highlighted and the name of the state/county displayed.
I need to do this so that I can display the COVID-19 data that I have.
library(ggplot2)
library(scales)
library(ggmap)
library(viridis)
dataset$id <- rownames("dataset")
newUS <- fortify(US3, region = "id")
newdf <- merge(newUS, US3@data, by = "id")
Myplot <- ggplot() +
geom_polygon(data = newdf, aes(fill = Bush_pct,
x = long,
y = lat,
group = group)) +
theme_nothing(legend = TRUE) + coord_map() + ggtitle("column_name") + theme(plot.title = element_text(hjust =0.5))
NicerPlot <- Myplot + scale_fill_viridis(option = "magma", direction = -1)
NicerPlot