list - R removing long duplicates from a vector -
suppose have a vector looks this, \n indicates new line:
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
i want remove duplicates left with
m # [1] aa\nbb\nff\ndd
any suggestions? much
the real data trying manipulate messy:
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"
for example trying rid of lines 4 , 6, because exact duplicates of 3 , 5.
i think key function use duplicated
. then
m[!m %in% m[duplicated(m)]]
will give elements not duplicated.
Comments
Post a Comment