title: Reshaping large dataset in R
body: <p>I am trying to reshape a large dataset and have a problem not getting the results in the right order as I want to.</p>
  
  <p>Here is what the data looks like:</p>
  
  <pre><code>GeoFIPS GeoName IndustryID  Description X2001   X2002   X2003   X2004   X2005 
  10180   Abilene, TX     21  Mining      96002   92407   127138 150449   202926
  10180   Abilene, TX     22  Utilities   33588   34116   33105   33265   32452
  ...
  </code></pre>
  
  <p>The dataframe is very long and includes all MSAs in the US with selected Industry sectors.</p>
  
  <p>The way I wanted it to look like is this:</p>
  
  <pre><code>GeoFIPS GeoName        Year     Mining Utilities (etc)
  10180   Abilene, TX    2001     96002   33588
  10180   Abilene, TX    2002     92407   34116
  ....
  </code></pre>
  
  <p>I am pretty new to R and would really appreciate your help.
  I have checked wide to long and long to wide, but this seems to be a more complex situation. 
  Thank you!</p>
  
  <p>Edit:
  <strong>Data</strong></p>
  
  <pre><code>df1 &lt;- structure(list(GeoFIPS = c(10180L, 10180L), GeoName =
  c("Abilene, TX", 
  "Abilene, TX"), IndustryID = 21:22, Description = c("Mining", 
  "Utilities"), X2001 = c(96002L, 33588L), X2002 = c(92407L, 34116L
  ), X2003 = c(127138L, 33105L), X2004 = c(150449L, 33265L), X2005 = 
  c(202926L, 
   32452L)), .Names = c("GeoFIPS", "GeoName", "IndustryID", "Description", 
  "X2001", "X2002", "X2003", "X2004", "X2005"), class = "data.frame",
   row.names = c(NA, -2L))
  </code></pre>