title: ggplot/mapping US counties — problems with visualization shapes in R
body: <p>So I have a data frame in R called obesity_map which basically gives me the state, county, and obesity rate per county. It looks more or less like this:</p>
  <pre><code>obesity_map = data.frame(state, county, obesity_rate)
  </code></pre>
  <p>I'm trying to visualize this on the map by showing various obesity rates per county throughout the US with this:</p>
  <pre><code>us.state.map &lt;- map_data('state')
  head(us.state.map)
  states &lt;- levels(as.factor(us.state.map$region))
  df &lt;- data.frame(region = states, value = runif(length(states), min=0, max=100),stringsAsFactors = FALSE)
  
  map.data &lt;- merge(us.state.map, df, by='region', all=T)
  map.data &lt;- map.data[order(map.data$order),]
  head(map.data)
  
  map.county &lt;- map_data('county')
  county.obesity &lt;- data.frame(region = obesity_map$state, subregion = obesity_map$county, value = obesity_map$obesity_rate)
  map.county &lt;- merge(county.obesity, map.county, all=TRUE)
  ggplot(map.county, aes(x = long, y = lat, group=group, fill=as.factor(value))) + geom_polygon(colour = &quot;white&quot;, size = 0.1)
  </code></pre>
  <p>And it basically creates an image that looks like this:</p>
  <p><img src="https://i.imgur.com/RQKjpxH.png" alt="img" /></p>
  <p>As you can see, the US is divided into strange shapes, the colors aren't one consistent color in varying gradients, and you can't make much from it. But what I really want is something like this below but with each county filled in:</p>
  <p><img src="https://i.imgur.com/vZU9cEg.png" alt="img2" /></p>
  <p>I'm fairly new to this so I'd appreciate any and all help!</p>
  <hr />
  <p>Edit:</p>
  <p>Here's the output of the dput:</p>
  <pre><code>dput(obesity_map)
  </code></pre>
  <pre><code>structure(list(X = 1:3141, FIPS = c(1L, 3L, 5L, 7L, 9L, 11L, 
  13L, 15L, 17L, 19L, 21L, 23L, 25L, 27L, 29L, 31L, 33L, 35L, 37L, 
  39L, 41L, 43L, 45L, 47L, 49L, 51L, 53L, 55L, 57L, 59L, 61L, 63L, 
  65L, 67L, 69L, 71L, 73L, 75L, 77L, 79L, 81L, 83L, 85L, 87L, 89L, 
  91L, 93L, 95L, 97L, 99L, 101L, 103L, 105L, 107L, 109L, 111L, 
  113L, 115L, 117L, 119L, 121L, 123L, 125L, 127L, 129L, 131L, 133L, 
  13L, 16L, 20L, 50L, 60L, 68L, 70L, 90L, 100L, 110L, 122L, 130L, 
  150L, 164L, 170L, 180L, 185L, 188L, 201L, 220L, 232L, 240L, 261L, 
  270L, 280L, 282L, 290L, 1L, 3L, 5L, 7L, 9L, 11L, 12L, 13L, 15L, 
  17L, 19L, 21L, 23L, 25L, 27L, 1L, 3L, 5L, 7L, 9L, 11L, 13L, 15L, 
  17L, 19L, 21L, 23L, 25L, 27L, 29L, 31L, 33L, 35L, 37L, 39L, 41L, 
  </code></pre>
  <p>It's a huge amount of numbers because it's for every US county so I abbreviated the results and put in the first couple lines.</p>
  <p>Basically, the data frame looks like this though:</p>
  <pre><code>print(head(obesity_map))
  
  
    X FIPS state_names county_names obesity
  1 1    1     Alabama      Autauga    24.5
  2 2    3     Alabama      Baldwin    23.6
  3 3    5     Alabama      Barbour    25.6
  4 4    7     Alabama         Bibb     0.0
  5 5    9     Alabama       Blount    24.2
  6 6   11     Alabama      Bullock     0.0
  </code></pre>
  <p>I also tried using ggcounty by following the example put up but I keep getting an error. I'm not entirely sure what I've done wrong:</p>
  <pre><code>library(ggcounty)
  
  # breaks
  obesity_map$obese &lt;- cut(obesity_map$obesity, 
                    breaks=c(0, 5, 10, 15, 20, 25, 30), 
                    labels=c(&quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot;4&quot;, 
                             &quot;5&quot;, &quot;6&quot;),
                    include.lowest=TRUE)
  
  # get the US counties map (lower 48)
  us &lt;- ggcounty.us()
  
  # start the plot with our base map
  gg &lt;- us$g
  
  # add a new geom with our population (choropleth)
  gg &lt;- gg + geom_map(data=obesity_map, map=us$map,
                  aes(map_id=FIPS, fill=obesity_map$obese), 
                  color=&quot;white&quot;, size=0.125)
  </code></pre>
  <p>But I always end up getting an error saying: &quot;Error: Argument must be coercible to non-negative integer&quot;</p>
  <p>Any idea? Thanks again for all your help! I appreciate it so much.</p>