0

I have a data.frame that looks like this:

  #row.name   #col1         #col2   
   MAP4K3     Centrosome
   STK32A     Centrosome    Cytosol
   ADCK2      Centrosome    

what I'd like to achieve is a new row duplicating the name and adding at the first column the value of the second column:

  #row.name   #col1            
   MAP4K3     Centrosome
   STK32A     Centrosome
   STK32A     Cytosol
   ADCK2      Centrosome    

I'd like to loop this through the entire data.frame.

Thank you

Enrico T.
  • 1
  • 2
  • Can you use the `melt()` function? I think the only limitation would be turning the row names into an actual column. – Travis Gaddie Jan 30 '17 at 14:28
  • Related: [reshape from wide to long](http://stackoverflow.com/questions/2185252/reshaping-data-frame-from-wide-to-long-format). – lmo Jan 30 '17 at 14:32

0 Answers0