title: Recasting specific dataframe columns in R
body: <p>I have a data frame of three columns:<code>title</code>, <code>text</code> and <code>grp</code>.</p>
  <p>The data frame looks like this:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: center;">title</th>
  <th style="text-align: center;">text</th>
  <th style="text-align: center;">grp</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: center;"><strong>Week 2</strong></td>
  <td style="text-align: center;">In Week 2 the encoding...</td>
  <td style="text-align: center;">2</td>
  </tr>
  <tr>
  <td style="text-align: center;">comments</td>
  <td style="text-align: center;"><em>collection of comments about <strong>Week 2</strong></em></td>
  <td style="text-align: center;">2</td>
  </tr>
  <tr>
  <td style="text-align: center;"><strong>Statistics</strong></td>
  <td style="text-align: center;">Statistics is the discipline...</td>
  <td style="text-align: center;">3</td>
  </tr>
  <tr>
  <td style="text-align: center;">comments</td>
  <td style="text-align: center;"><em>collection of comments about <strong>Statistics</strong></em></td>
  <td style="text-align: center;">3</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I want to add the <code>comments</code> as columns to this dataframe and keep the value as its text corresponding to each title.</p>
  <p>desired dataframe:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: center;">title</th>
  <th style="text-align: center;">text</th>
  <th style="text-align: center;">comments</th>
  <th style="text-align: center;">grp</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: center;"><strong>Week 2</strong></td>
  <td style="text-align: center;">In Week 2 the encoding...</td>
  <td style="text-align: center;"><em>colection of comments about <strong>Week 2</strong></em></td>
  <td style="text-align: center;">2</td>
  </tr>
  <tr>
  <td style="text-align: center;"><strong>Statistics</strong></td>
  <td style="text-align: center;">Statistics is the discipline...</td>
  <td style="text-align: center;"><em>collection of comments about <strong>Statistics</strong></em></td>
  <td style="text-align: center;">3</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I tried re-casting:</p>
  <pre><code>library(reshape2)
  
  recast(df, text ~ comment, id.var = c(&quot;text&quot;))
  </code></pre>
  <p>But gives me an error:</p>
  <pre><code>Error in unique.default(x) : unique() applies only to vectors
  </code></pre>