I am using ggplot2 to plot a map of the United States and Canada, and I want to display outlines of the US States and the Canadian Provinces. I was able to outline the US States using map_data("state") within geom_polygon() function, but get an error that map_data("Province") or map_data("Canada"), or anything associated with Canada, is not an exported object within maps.
The attached photo is my current output - I would like it to look exactly the same but with the Canadian Province outlines. My current code is below.
library(ggplot2)
library(sf)
library(rnaturalearth)
library(rnaturalearthdata)
library(rgeos)
library(raster)
#State/Province outlines
states <- map_data("state")
provinces <- map_data("province")
ggplot(data = world) +
geom_sf() +
xlab("Longitude") +
ylab("Latitude") +
geom_polygon(data = states, aes(x = long, y = lat, group = group), color = "black", fill = "antiquewhite") +
coord_sf(xlim = c(-130, -65), ylim = c(25,58.5), expand = FALSE) +
annotate(geom = "text", x = -100, y = 40, label = "United States", fontface = "italic", color = "grey22", size = 3) +
annotate(geom = "text", x = -100, y = 52.5, label = "Canada", fontface = "italic", color = "grey22", size = 3) +
theme(panel.grid.major = element_line(color = gray(.5), linetype = "dashed", size = 0.5),
panel.background = element_rect(fill = "paleturquoise1"))