# load needed libraries
library(ggplot2)
library(dplyr)
library(maps)
library(mapproj)

# choose a dataset
data <- USArrests
data$state <- tolower(rownames(data))

# get a map of the US
us_map <- map_data("state")

# merge state data with map data
us_map <- left_join(us_map, data, by = c("region" = "state"))

# plot the map
ggplot() +
  geom_map(
    data = us_map,
    map = us_map,
    mapping = aes(x = long, y = lat, map_id = region, fill = Murder),
    color = "white",
    size = 0.2
  ) +
  scale_fill_gradient(low = "lightblue", high = "darkblue", name = "Murder Rate") +
  coord_map("polyconic") +
  theme_void() +
  labs(title = "Murder Rate by State in the US")