title: Coercing a column of lists into a string in an R data frame
body: <p>Create sample data:    </p>
  
  <pre><code>id &lt;- c(12, 32, 42, 42, 52, 52, 67, 67)
  relationship_id &lt;- c(15,1,59,1,61,6,59,1)
  sample.data &lt;- data.frame(id,relationship_id)
  </code></pre>
  
  <p>For each id that appears more than once, concatenate the relationship_id:</p>
  
  <pre><code>combo &lt;- aggregate(relationship_id ~ id, data = sample.data, paste, sep=",")
  table(combo$relationship_id)
  Error in table(combo$relationship_id) :
    all arguments must have the same length
  </code></pre>
  
  <p>I figured out what caused this error: </p>
  
  <pre><code>class(combo$relationship_id)
  [1] "list"
  </code></pre>
  
  <p>But when I try and coerce the list vector to a character vector: </p>
  
  <pre><code>combo["relationship_id"] &lt;- lapply(combo["relationship_id"], as.character)
  &gt; head(combo)    
    id relationship_id
  1 12              15
  2 32               1
  3 42    c("59", "1")
  4 52    c("61", "6")
  5 67    c("59", "1")
  </code></pre>
  
  <p>It includes the concatenation syntax... I understand that I can parse the output so that it is usable, but why is this happening? Is there an easier way to clean up the output?</p>