title: geom_map all subregions the same color
body: <p>I'm attempting to move over from older ways of mapping data to a choropleth now that ggplot2 has the geom_map.  An example is seen on pp. 10-11 (<a href="http://cloud.github.com/downloads/hadley/ggplot2/guide-col.pdf" rel="nofollow noreferrer">HERE</a>).  </p>
  
  <p>I'm attempting to do this with a data set I've created a choropleth from in the past just not with ggplot's new geom_map.  Here's my attempt that I think is like Hadely's example but everything is the same color.</p>
  
  <p>The data set and code:</p>
  
  <pre><code>#loads 2 data frames: ny and cad from my drop box
  load(url("http://dl.dropbox.com/u/61803503/MAPPING.RData"))
  library(ggplot2)
  
  ggplot(cad, aes(map_id = subregion)) +
      geom_map(aes(fill = Math_Pass_Rate), map = ny) +
      expand_limits(x = ny$long, y = ny$lat) +
      guides(fill = guide_colorbar(colours = topo.colors(10))) +
      opts(legend.position = "top")
  </code></pre>
  
  <p>Why is it showing up as the same color?</p>
  
  <hr>
  
  <p>Additional information from @PaulHiemstra</p>
  
  <p>I've puzzling a bit on it, and could not get a good result. However, I also wonder why the example from the ggplot2 pdf you link to works. </p>
  
  <p>This code produces a correct choropleth map.</p>
  
  <pre><code>crimes &lt;- data.frame(state = tolower(rownames(USArrests)), USArrests)
  states_map &lt;- map_data("state")
  ggplot(crimes, aes(map_id = state)) +
     geom_map(aes(fill = Murder), map = states_map) +
     expand_limits(x = states_map$long, y = states_map$lat) +
     guides(fill = guide_colorbar(colours = topo.colors(10))) +
     opts(legend.position = "top")
  </code></pre>
  
  <p>One would expect that by using <code>map_id = state</code>, that a link was made between a column in <code>states_map</code> (the polygons) and a column in <code>crimes</code> (<code>Murder</code>). <code>crimes</code> contains a <code>state</code> column:</p>
  
  <pre><code>&gt; head(crimes)
                  state Murder Assault UrbanPop Rape
  Alabama       alabama   13.2     236       58 21.2
  Alaska         alaska   10.0     263       48 44.5
  Arizona       arizona    8.1     294       80 31.0
  Arkansas     arkansas    8.8     190       50 19.5
  California california    9.0     276       91 40.6
  Colorado     colorado    7.9     204       78 38.7
  </code></pre>
  
  <p>but <code>states_map</code> does not:</p>
  
  <pre><code>&gt; head(states_map)
         long      lat group order  region subregion
  1 -87.46201 30.38968     1     1 alabama      &lt;NA&gt;
  2 -87.48493 30.37249     1     2 alabama      &lt;NA&gt;
  3 -87.52503 30.37249     1     3 alabama      &lt;NA&gt;
  4 -87.53076 30.33239     1     4 alabama      &lt;NA&gt;
  5 -87.57087 30.32665     1     5 alabama      &lt;NA&gt;
  6 -87.58806 30.32665     1     6 alabama      &lt;NA&gt;
  </code></pre>
  
  <p>So in the link between the polygons and the data, some black magic seems to be happening. This might also explain the problems @TylerRinker has.</p>