我的数据看起来是这样的:
> dput(dd)
structure(list(TestGroups = c("P61294;Q0PD53", "O55143", "P16330;Q3TYV5",
"P61979;Q3TUA1;Q5FWJ5", "P68037;Q561N4", "H3BL37;O08784;Q05BH6;Q7TPZ2",
"A0A0R4IZX5;P55066", "P27601;Q3UE40", "P11930", "Q9QXS6", "Q9D0K2"
), Ids = c("P61294;Q0PD53", "O55143", "P16330;Q3TYV5", "P61979;Q3TUA1;Q5FWJ5",
"P68037;Q561N4", "H3BL37;O08784;Q05BH6;Q7TPZ2", "A0A0R4IZX5;P55066",
"P27601;Q3UE40", "P11930", "Q9QXS6", "Q9D0K2"), Test.Name = c("RAB6B_ART;Q0PD53_ART",
"AT2A2_ART", "CN37_ART;Q3TYV5_ART", "HNRPK_ART;Q3TUA1_ART;Q5FWJ5_ART",
"UB2L3_ART;Q561N4_ART", "H3BL37_ART;TCOF_ART;Q05BH6_ART;Q7TPZ2_ART",
"A0A0R4IZX5_ART;NCAN_ART", "GNA13_ART;Q3UE40_ART", "NUD19_ART",
"DREB_ART", "SCOT1_ART"), TestDescription = c("Mark", "Barry",
"Dirk", "Greg", "Tom", "Tom", "Jerry", "Orfa", "Morso", "Orx",
"Tesra"), Factors = c("Rab6b", "Atp2a2", "Cnp", "Hnrnpk", "Ube2l3",
"Tcof1", "Ncan", "Gna13", "Nudt19", "Dbn1", "Oxct1"), Removed_part = c("TDLADKR",
"DACLNAR", "AAARK", "HESGASIK", "NAEEFTK", "TGPAATQAK", "VQTASGQR",
"TDLLEEK", "DTTTFLEK", "TDAAVEMK", "SGKPGGDVR")), row.names = c(62L,
72L, 80L, 96L, 116L, 128L, 139L, 154L, 163L, 172L, 189L), class = "data.frame")
我想通过添加一个额外的行来分隔TestGroups
列中的字符串。例如,让我们以第一行为例:
P61294;Q0PD53 P61294;Q0PD53 RAB6B_ART;Q0PD53_ART Mark Rab6b TDLADKR
这就是我想要的输出结果:
P61294 P61294;Q0PD53 RAB6B_ART;Q0PD53_ART Mark Rab6b TDLADKR
Q0PD53 P61294;Q0PD53 RAB6B_ART;Q0PD53_ART Mark Rab6b TDLADKR
正如你所看到的,只有第一列的字符串被提取并分隔并放在不同的行中,其余的列只是被复制/复制。也可能发生在TestGroups
列中有超过2个字符串。请注意,我想删除分隔标记';只保留纯粹的名字
1条答案
按热度按时间7xllpg7q1#
我们可以使用
separate_longer_delim()
: