首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >R从向量中移除长的重复

R从向量中移除长的重复
EN

Stack Overflow用户
提问于 2015-07-18 05:25:11
回答 1查看 53关注 0票数 0

假设我有一个如下所示的向量,其中\n表示一条新行:

代码语言:javascript
复制
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

我想要删除所有的副本,这样您就可以使用

代码语言:javascript
复制
m
# [1] AA\nBB\nFF\nDD

有什么建议吗?非常感谢

我试图处理的真实数据非常混乱:

代码语言:javascript
复制
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的完全重复。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-07-18 05:46:28

我认为要使用的关键函数是duplicated。然后

代码语言:javascript
复制
m[!m %in% m[duplicated(m)]]

将为您提供所有不重复的元素。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31488084

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档