title: Reshape data frame to convert factors into columns in R
body: <p>I have a data frame where one particular column has a set of specific values (let's say, 1, 2, ..., 23). What I would like to do is to convert from this layout to the one, where the frame would have extra 23 (in this case) columns, each one representing one of the factor values. The data in these columns would be booleans indicating whether a particular row had a given factor value... To show a specific example:</p>
  
  <p>Source frame:</p>
  
  <pre><code>ID       DATE         SECTOR
  123      2008-01-01   1
  456      2008-01-01   3
  789      2008-01-02   5
  ... &lt;more records with SECTOR values from 1 to 5&gt;
  </code></pre>
  
  <p>Desired format:</p>
  
  <pre><code>ID       DATE         SECTOR.1   SECTOR.2   SECTOR.3   SECTOR.4   SECTOR.5
  123      2008-01-01      T          F          F          F          F
  456      2008-01-01      F          F          T          F          F
  789      2008-01-02      F          F          F          F          T
  </code></pre>
  
  <p>I have no problem doing it in a loop but I hoped there would be a better way. So far <code>reshape()</code> didn't yield the desired result. Help would be much appreciated.</p>