0

I have the following table:

sp0000001-mRNA-1    
sp0000005-mRNA-1    GO:0003723
sp0000006-mRNA-1    GO:0016021
sp0000007-mRNA-1    GO:0003700|GO:0006355|GO:0043565

The aim would be to generate new rows for GO ids which were separated by |. From the above example it would lead to 2 more rows

sp0000001-mRNA-1    
sp0000005-mRNA-1    GO:0003723
sp0000006-mRNA-1    GO:0016021
sp0000007-mRNA-1    GO:0003700
sp0000007-mRNA-1    GO:0006355
sp0000007-mRNA-1    GO:0043565

How is it possible to do it R?

Thank you in advance

4
  • library(splitstackshape); cSplit(df, "V2", "|", "long")
    – Ronak Shah
    Sep 14, 2017 at 3:19
  • tidyr::separate_rows
    – Brian
    Sep 14, 2017 at 3:20
  • tidyr::unnest
    – BENY
    Sep 14, 2017 at 3:24
  • is there any performance difference between the above solutions?
    – user977828
    Sep 14, 2017 at 21:45

0

Browse other questions tagged or ask your own question.