title: Combine column values with partially matching names into one semicolon-separated field in R
body: <p>I've looked through SO and have not found any advice that accurately explains what I am looking for.</p>
  
  <p>I have a giant table. The first few columns have information about different expressed transcripts and the SNP which influences it. The remainder of the columns (of which there are around a thousand) are either information about an individual's tissue sample (with a column header such as <code>GTEX.11DXX.1426.SM.5GIDU</code>) or the individual's ID (<code>GTEX.11DXX</code>). The information under these columns contain either the number of transcripts expressed (e.g. <code>92</code>) at that particular sequence and a binary value representing whether the allele that influences the expression of that transcript is Neandertal inherited or not (<code>1 or 0</code>), respectively.</p>
  
  <p>What I want to do is consolidate the data underneath the binary columns with the data underneath the transcript number columns like so:</p>
  
  <pre><code>GTEX.11DXX.1426.SM.5GIDU
  0;25
  1;74
  1;104
  1;92
  0;12
  ...
  etc.
  </code></pre>
  
  <p>I want to accomplish this by partially matching the column name <code>GTEX.11DXX</code> with <code>GTEX.11DXX.1426.SM.5GIDU</code>, and then getting rid of binary columns so it's just the long column names.</p>
  
  <p>I've tried using <code>tidyverse</code>'s <code>map(v, ~select_(ovary, ~matches(.)))</code>, and it kind of works, but that matches even if a one character is off, like so:</p>
  
  <pre><code>[[49]]
         GTEX.13X6H.1026.SM.5SIBE GTEX.13X6H GTEX.13X6I GTEX.13X6J GTEX.13X6K
      1:                       49          0          0          0          1
      2:                       44          0          0          0          1
      3:                        3          0          0          0          1
      4:                       23          0          0          0          1
      5:                       78          0          0          0          1
     ---                                                                     
  80285:                       84          1          0          0          0
  80286:                        1          1          0          0          0
  80287:                        0          1          0          0          0
  80288:                      152          1          0          0          0
  80289:                      120          1          0          0          0
  </code></pre>
  
  <p>Again, I want to to work like this:</p>
  
  <pre><code>       GTEX.13X6H.1026.SM.5SIBE
      1:                     0;49
      2:                     0;44
      3:                      0;3
      4:                     0;23
  </code></pre>
  
  <p>Thank you</p>