title: Create New Data Frame with Column Names from Unique Values in another Data Frame and Corresponding Values Assigned to Column
body: <p>I'm new to R, and I'm pretty sure this is something simple to accomplish, but I cannot figure out how to perform this action. I've tried the split function, utilizing a for loop, but cannot quite figure out how to get it right. As an example, this is what my original data frame looks like:</p>
  
  <pre><code>dat &lt;- data.frame(col1 = c(rep("red", 4), rep("blue", 3)), col2 = c(1, 3, 2, 4, 7, 8, 9))
  
   col1 col2
    red    1
    red    3
    red    2
    red    4
   blue    7
   blue    8
   blue    9
  </code></pre>
  
  <p>I want to create new columns for each unique value in col1 and assign it's corressponding value in col2 to the new data frame. And this is how I want my new data frame:</p>
  
  <pre><code>red  blue
   1       7
   3       8
   2       9
   4      NA
  </code></pre>
  
  <p>I've gotten close with a list structure close to what I wanted, but I need a data frame to boxplot and dotplot the results. Any help would be appriciated. Thanks!</p>