1

I'm trying to plot election results on the US map with the usmap package but even though the dataset is complete, I get plot that shows missing values for some states. The states are greyed out and I'm not sure why this is happening..

enter image description here

plot_usmap(data=data_total,values='percent_biden')+
  scale_fill_continuous(low='red',high='blue',name='Percent for Biden')+
  theme(legend.position='right')+
  ggtitle(paste("Total Popular Vote of Final Results"))

enter image description here

r2evans
  • 141,215
  • 6
  • 77
  • 149
  • 3
    It will be easier to help if you include your code. – da11an Dec 14 '20 at 18:53
  • 1
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Dec 14 '20 at 19:07

1 Answers1

1

You are incorrectly assuming that usmap will infer any format for state names. For instance, both of these produce a working map,

usmap::plot_usmap(data=data.frame(state=c("alabama","new york"),s=c(5,15)), values="s")
usmap::plot_usmap(data=data.frame(state=c("AL","NY"),s=c(5,15)), values="s")

two states, take 1

whereas inferring from your pic of data, you are trying

usmap::plot_usmap(data=data.frame(state=c("alabama","new-york"),s=c(5,15)), values="s")
#                                                       ^ dash, not space

alabama alone

So I believe you need to clean up your data and fix your state names.

r2evans
  • 141,215
  • 6
  • 77
  • 149