title: reshaping data from long to wide format un R
body: <p>I am looking for a way to reshape my data:</p>
  <pre><code>&gt; test
        policyID startYear   product
  1: G000246-000      2014 Product 1
  2: G000246-000      2014 Product 2
  3: G000246-000      2014 Product 3
  4: G000246-000      2015 Product 1
  5: G000246-000      2015 Product 2
  6: G000246-000      2015 Product 3
  </code></pre>
  <p>to this:</p>
  <pre><code>     policyID       2014         2015
  1: G000246-000    Product 1    Product 1
  2: G000246-000    Product 2    Product 2
  3: G000246-000    Product 3    Product 3
  </code></pre>
  <p>I have tried:</p>
  <pre><code>  reshape(test, idvar = &quot;policyID&quot;, timevar = &quot;startYear&quot;, direction = &quot;wide&quot;)
  </code></pre>
  <p>but i get:</p>
  <pre><code>      policyID product.2014 product.2015
  1: G000246-000    Product 1    Product 1
  </code></pre>
  <p><strong>Whats the best approach to get to my desired results?</strong></p>
  <p>DATA:</p>
  <pre><code>structure(list(policyID = c(&quot;G000246-000&quot;, &quot;G000246-000&quot;, &quot;G000246-000&quot;, 
  &quot;G000246-000&quot;, &quot;G000246-000&quot;, &quot;G000246-000&quot;), startYear = c(2014, 
  2014, 2014, 2015, 2015, 2015), product = c(&quot;Product 1&quot;, &quot;Product 2&quot;, 
  &quot;Product 3&quot;, &quot;Product 1&quot;, &quot;Product 2&quot;, &quot;Product 3&quot;)), row.names = c(NA, 
  -6L), class = c(&quot;data.table&quot;, &quot;data.frame&quot;))
  </code></pre>