假设我有一个如下所示的向量,其中\n表示一条新行:
m
# [1] AA\nBB\nCC\nDD
# [2] AA\nBB\nEE\nDD
# [3] AA\nBB\nEE\nDD
# [4] AA\nBB\nCC\nDD
# [5] AA\nBB\nFF\nDD我想要删除所有的副本,这样您就可以使用
m
# [1] AA\nBB\nFF\nDD有什么建议吗?非常感谢
我试图处理的真实数据非常混乱:
head(m)
[1] "FT motif 619..622\nFT /note=GATC\nFT /color=48 249 173\nFT motif complement(619..622)\nFT /note=GATC\nFT /color=48 249 173\nFT motif 8662..8667\nFT /note=CTGCAG\nFT /color=90 236 150\nFT motif complement(8662..8667)\nFT /note=CTGCAG\nFT /color=90 236 150\nFT motif 205..210\nFT /note=ACCACC\nFT /color=197 13 106\nFT motif complement(205..210)\nFT /note=ACCACC\nFT /color=197 13 106\nFT motif 419..423\nFT /note=CC(A|T)GG\nFT /color=252 213 234\nFT motif complement(419..423)\nFT /note=CC(A|T)GG\nFT /color=252 213 234\nFT motif 16843..16858\nFT /note=CCAC.{8}TGA(C|T)\nFT /color=132 205 77\nFT motif complement(16843..16858)\nFT /note=CCAC.{8}TGA(C|T)\nFT /color=132 205 77"
[2] "FT motif 726..729\nFT /note=GATC\nFT /color=48 249 173\nFT motif complement(726..729)\nFT /note=GATC\nFT /color=48 249 173\nFT motif 13022..13027\nFT /note=CTGCAG\nFT /color=90 236 150\nFT motif complement(13022..13027)\nFT /note=CTGCAG\nFT /color=90 236 150\nFT motif 214..219\nFT /note=ACCACC\nFT /color=197 13 106\nFT motif complement(214..219)\nFT /note=ACCACC\nFT /color=197 13 106\nFT motif 474..478\nFT /note=CC(A|T)GG\nFT /color=252 213 234\nFT motif complement(474..478)\nFT /note=CC(A|T)GG\nFT /color=252 213 234\nFT motif 33075..33090\nFT /note=CCAC.{8}TGA(C|T)\nFT /color=132 205 77\nFT motif complement(33075..33090)\nFT /note=CCAC.{8}TGA(C|T)\nFT /color=132 205 77"
[3] "FT motif 781..784\nFT /note=GATC\nFT /color=48 249 173\nFT motif complement(781..784)\nFT /note=GATC\nFT /color=48 249 173\nFT motif 13132..13137\nFT /note=CTGCAG\nFT /color=90 236 150\nFT motif complement(13132..13137)\nFT /note=CTGCAG\nFT /color=90 236 150\nFT motif 470..475\nFT /note=ACCACC\nFT /color=197 13 106\nFT motif complement(470..475)\nFT /note=ACCACC\nFT /color=197 13 106\nFT motif 507..511\nFT /note=CC(A|T)GG\nFT /color=252 213 234\nFT motif complement(507..511)\nFT /note=CC(A|T)GG\nFT /color=252 213 234\nFT motif 36423..36438\nFT /note=CCAC.{8}TGA(C|T)\nFT /color=132 205 77\nFT motif complement(36423..36438)\nFT /note=CCAC.{8}TGA(C|T)\nFT /color=132 205 77"
[4] "FT motif 781..784\nFT /note=GATC\nFT /color=48 249 173\nFT motif complement(781..784)\nFT /note=GATC\nFT /color=48 249 173\nFT motif 13132..13137\nFT /note=CTGCAG\nFT /color=90 236 150\nFT motif complement(13132..13137)\nFT /note=CTGCAG\nFT /color=90 236 150\nFT motif 470..475\nFT /note=ACCACC\nFT /color=197 13 106\nFT motif complement(470..475)\nFT /note=ACCACC\nFT /color=197 13 106\nFT motif 507..511\nFT /note=CC(A|T)GG\nFT /color=252 213 234\nFT motif complement(507..511)\nFT /note=CC(A|T)GG\nFT /color=252 213 234\nFT motif 36423..36438\nFT /note=CCAC.{8}TGA(C|T)\nFT /color=132 205 77\nFT motif complement(36423..36438)\nFT /note=CCAC.{8}TGA(C|T)\nFT /color=132 205 77"
[5] "FT motif 1167..1170\nFT /note=GATC\nFT /color=48 249 173\nFT motif complement(1167..1170)\nFT /note=GATC\nFT /color=48 249 173\nFT motif 16052..16057\nFT /note=CTGCAG\nFT /color=90 236 150\nFT motif complement(16052..16057)\nFT /note=CTGCAG\nFT /color=90 236 150\nFT motif 14262..14267\nFT /note=ACCACC\nFT /color=197 13 106\nFT motif complement(14262..14267)\nFT /note=ACCACC\nFT /color=197 13 106\nFT motif 1207..1211\nFT /note=CC(A|T)GG\nFT /color=252 213 234\nFT motif complement(1207..1211)\nFT /note=CC(A|T)GG\nFT /color=252 213 234\nFT motif 44826..44841\nFT /note=CCAC.{8}TGA(C|T)\nFT /color=132 205 77\nFT motif complement(44826..44841)\nFT /note=CCAC.{8}TGA(C|T)\nFT /color=132 205 77"
[6] "FT motif 1167..1170\nFT /note=GATC\nFT /color=48 249 173\nFT motif complement(1167..1170)\nFT /note=GATC\nFT /color=48 249 173\nFT motif 16052..16057\nFT /note=CTGCAG\nFT /color=90 236 150\nFT motif complement(16052..16057)\nFT /note=CTGCAG\nFT /color=90 236 150\nFT motif 14262..14267\nFT /note=ACCACC\nFT /color=197 13 106\nFT motif complement(14262..14267)\nFT /note=ACCACC\nFT /color=197 13 106\nFT motif 1207..1211\nFT /note=CC(A|T)GG\nFT /color=252 213 234\nFT motif complement(1207..1211)\nFT /note=CC(A|T)GG\nFT /color=252 213 234\nFT motif 44826..44841\nFT /note=CCAC.{8}TGA(C|T)\nFT /color=132 205 77\nFT motif complement(44826..44841)\nFT /note=CCAC.{8}TGA(C|T)\nFT /color=132 205 77"例如,我试图去掉第4行和第6行,因为它们是3和5的完全重复。
发布于 2015-07-18 05:46:28
我认为要使用的关键函数是duplicated。然后
m[!m %in% m[duplicated(m)]]将为您提供所有不重复的元素。
https://stackoverflow.com/questions/31488084
复制相似问题