gglot showing wrong state data

It is better, but next time please try to make a complete self-contained reproducible example (as explained in the guide).

I think your problem is the use of merge() try with left_join() instead, see this reprex

library(tidyverse)
library(ggmap)

states <- map_data("state")

AEP <- data.frame(Impressions = c(9434L, 10060L, 5686L, 22694L, 5998L), 
                  region = as.factor(c("alabama", "arizona", "arkansas", "california", 
                                       "colorado")))

mapdata <- states %>% 
    left_join(AEP, by="region")

ggplot(data = mapdata) +
    geom_polygon(mapping = aes(x=long,y=lat,group=group, fill=Impressions))

3 Likes