title: Reshaping data.frame with a by-group where id variable repeats
body: <p>I want to reshape/ rearrange a dataset, that is stored as a data.frame with 2 columns: </p>
  
  <ul>
  <li>id (non-unique, i.e. can repeat over several rows) --> stored as character</li>
  <li>value --> stored as numeric value (range 1:3)</li>
  </ul>
  
  <p>Sample data:</p>
  
  <pre><code>id &lt;- as.character(1001:1003)
  val_list &lt;- data.frame(sample(1:3, size=12, replace=TRUE))
  have &lt;- data.frame(cbind(rep(id, 4), val_list))
  colnames(have) &lt;- c("id", "values")
  have &lt;- have %&gt;% arrange(id)
  </code></pre>
  
  <p>This gives me the following output:</p>
  
  <pre><code>   id   values
  1  1001      2
  2  1001      2
  3  1001      2
  4  1001      3
  5  1002      2
  6  1002      3
  7  1002      2
  8  1002      2
  9  1003      1
  10 1003      3
  11 1003      1
  12 1003      2
  </code></pre>
  
  <p>What I want:</p>
  
  <pre><code>want &lt;- data.frame(cbind(have[1:4, 2], 
                       have[5:8, 2],
                       have[9:12, 2]))
  colnames(want) &lt;- id
  </code></pre>
  
  <p>Output of want:</p>
  
  <pre><code>    1001 1002 1003
    1    2    2    1
    2    2    3    3
    3    2    2    1
    4    3    2    2
  </code></pre>
  
  <p>My original dataset has >1000 variables "id" and >50 variables "value". 
  I want to chunk/ slice the dataset get a new data.frame where each "id" variable will represent one column listing its "value" variable content. </p>
  
  <p>It is possible to solve it via a loop, but I want to have the vectorized solution. 
  If possible with base R as "one-liner", but other solutions also appreciated.</p>