Hi guys,

I have R programming question: I have more than 1000 genes names `Names`. I want to match the samples containing those genes in `Names` and paste the corresponding gene with the ".AD" extension next to it in the same order to get the `Result` as shown below. Thank you.

```r
Names <- c("cebi", "pithe", "MAPK", "sapiens", "JUNK", "calli", "STR")
samples <- c("MAPK", "JUNK", "STR")
```

`Result`:

    "cebi", "pithe", "MAPK", "MAPK.AD", "sapiens", "JUNK", "JUNK.AD", "calli", "STR", "STR.AD"
```r
Names <- c("cebi","pithe","MAPK","sapiens","JUNK","calli","STR")
samples <- c("MAPK","JUNK","STR")

Result <- vector()
count <- 1

for(i in 1:length(Names)){
	index <- which(samples == Names[i])
	
	if(length(index) == 0){
		Result[count] <- Names[i]
		count <- count + 1
		next
	} else{
		Result[count] <- Names[i]
		count <- count + 1
		Result[count] <- paste(Names[i], ".AD", sep="")
		count <- count + 1
	}
}
```