1、
dat <- read.table("test.map",header = F) dat2 <- dat[c(1,4)] unique(sort(dat2$V1)) dat2[dat2$V1 == "X",]$V1 = 10000 dat2$V1 <- as.numeric(dat2$V1) dat2$V4 <- as.numeric(dat2$V4) dat3 <- dat2[order(dat2$V1,dat2$V4),] dat4 <- dat[duplicated(dat3),] dim(dat4) write.table(dat4$V2, "dup1.txt",col.names = F, row.names = F,quote = F,sep = "\t")
2、简化程序
dat <- read.table("test.map",header = F) dat2 <- dat[c(1,4)] dat3 <- dat[duplicated(dat2),] write.table(dat3$V2, "dup2.txt",col.names = F, row.names = F,quote = F,sep = "\t")