2017-06-22 36 views
3

對不起,可能有重複,但我甚至無法用文字描述我想要的內容。變換列表r

這裏是我有什麼現在(名單列表)

id1 one; two; three 
id2 one 
id3 one; two; three; four 
id4 one; two 

我需要得到

id1 one 
id1 two 
id1 three 
id2 one 
id3 one 

等等...幫助。 我需要這個從UniProt Retrieve ID表創建Blast2GO自定義.annot文件。

+0

你可能有興趣閱讀的概念「整潔的數據」:http://vita.had.co.nz/papers/tidy-data.pdf – bli

+1

只要做'library(splitstackshape); cSplit(df1,'col2',';','long')' – akrun

+0

試試'unlist'。 – CPak

回答

0

我們可以用cSplit這個

library(splitstackshape) 
cSplit(df1, 'col2', ';', 'long') 

注:假設第二列名是「COL2」和對象名稱爲「DF1」