Abstract
Below is a simple R program that allows you to create any colorful state. Simply run this code in an R IDE and then you can create any colorful state. Note that this can be applied for a variety of details in which you choose the content.
Colorful Map
Tyler
2024-03-03
R Markdown
library(tidyverse)
library(ggmap)
library(maps)
library(mapdata)
library(maptools)
library(ggthemes)
make_a_state = function(state, stateid){
str = 'Colorful'
map_data("county") -> usa
usa %>%
filter(region == state) -> stateid
names(stateid)
ggplot() +
geom_polygon(data = stateid, aes(x = long, y = lat, group = group, fill = subregion),
color = "white") +
coord_fixed(1.3) +
labs(title = paste(str, str_to_title(state))) +
ggthemes::theme_map() +
theme(plot.title=element_text(hjust=0.5), legend.position = "hide")}
make_a_state("nevada", ST)