0

I have a list of SNP names of length 2139. I have been trying to match each one of these names one a time to this character list of 23 rows, where each row contains multiple names so
that I can assign the locus name for each SNP.

I have tried grep and match and nothing is working. This shows the first 10 elements of my character vector that has the SNP names:

   [1] kgp32557    kgp37275    kgp38994    kgp45973    kgp53783      kgp61605    kgp73110    kgp74757   

And this shows the character list of 23 rows (truncated as well
because many names in each row so I show a list of names in row 1):

    [1,]   kgp9852430,rs1017860,rs7242868,kgp7009716,kgp6611434,kgp4808508,rs2850724,kgp3871878,kgp16151703,kgp16188651,rs9954562,kgp16153963,kgp7895020,....
Ed Morton
  • 188,023
  • 17
  • 78
  • 185
  • 1
    Please use `dput()`, and you can try `require(tidyverse) snpNames <- c("kgp32557", "kgp37275", "kgp38994", "kgp45973", "kgp53783", "kgp61605") snpMatch <- c("kgp32557", "kgp2345", "kgp2346", "kgp45973", "kgp53783", "kgp61605") snpMatch[snpNames %in% snpMatch]` – DJV Apr 18 '19 at 21:51
  • 1
    Please provide a [reproducible example in r](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). The link I provided, will tell you how. Moreover, please take the [tour](https://stackoverflow.com/tour) and visit [how to ask](https://stackoverflow.com/help/how-to-ask). Cheers. – M-- Apr 18 '19 at 22:01
  • Thank you...I will try this! – user5298556 Apr 19 '19 at 20:24
  • This is not working, I have wihsnoquote, a vector of 2136 names where I need to match each name to the row that has its name in genelocusnoquote which has 23 rows and 1 column. Each row of this matrix has a comma-delimited row where I gave an example of one row as shown above. This works going one one name and one row at a time but not in a loop: grep(wihsnamenoquote[1],genelocusnoquote[3,1]) Please help, thank you. – user5298556 Apr 22 '19 at 22:54

0 Answers0