title: How to concatenate different lines in a data frame columns based on another column value?
body: <p>I have a data.frame in R looking like this</p>
  
  <pre><code>&gt; mydata=data.frame(id=c(rep("gene1",3),rep("gene2",4),rep("gene3",1),rep("gene4",2)),description=c(rep("protein1",3),rep("protein2",4),rep("protein3",1),rep("protein4",2)),type=c(rep("coding",10)),name=c("nucleus","binding","ribosome","transcription factor","regulation of transcription","DNA","sequence-specific binding","hydrolase","transporter","ion transport"),definition=paste(rep("blabla",10),1:10))
  &gt; mydata
    id     description   type                        name definition
  1  gene1    protein1 coding                     nucleus   blabla 1
  2  gene1    protein1 coding                     binding   blabla 2
  3  gene1    protein1 coding                    ribosome   blabla 3
  4  gene2    protein2 coding        transcription factor   blabla 4
  5  gene2    protein2 coding regulation of transcription   blabla 5
  6  gene2    protein2 coding                         DNA   blabla 6
  7  gene2    protein2 coding   sequence-specific binding   blabla 7
  8  gene3    protein3 coding                   hydrolase   blabla 8
  9  gene4    protein4 coding                 transporter   blabla 9
  10 gene4    protein4 coding               ion transport   blabla 10
  </code></pre>
  
  <p>I need to transform it like this</p>
  
  <pre><code>&gt; mydata2=data.frame(id=c("gene1","gene2","gene3","gene4"),description=c("protein1","protein2","protein3","protein4"),type=c(rep("coding",4)),name=c("nucleus,binding,ribosome","transcription factor,regulation of transcription,DNA","sequence-specific binding","hydrolase,transporter,ion transport"),definition=paste(rep("blabla",4),c(3,7,8,10)))
  &gt; mydata2
      id description   type                                                 name   definition
  1 gene1    protein1 coding                             nucleus,binding,ribosome   blabla 3
  2 gene2    protein2 coding transcription factor,regulation of transcription,DNA   blabla 7
  3 gene3    protein3 coding                            sequence-specific binding   blabla 8
  4 gene4    protein4 coding                  hydrolase,transporter,ion transport   blabla 10
  </code></pre>
  
  <p>I have tried several functions</p>
  
  <pre><code>dcast
  reshape2
  spread
  </code></pre>
  
  <p>But I don't get what I need. For reshape2 for example, it creates a new column for each different entry in $name.</p>
  
  <p>Can someone help? Thanks a lot</p>
  
  <p>PS: first post, I hope the editing is ok, forgive me otherwise</p>