title: Single Allele to Biallelic Conditional on Major and Minor Allele Columns
body: <p>I have a data frame with several individuals as columns and SNPs as rows. Each column has a single allele (e.g. G or A or N (if not called). There are also columns with the major and (seperate column) minor alleles for each SNP. I am trying to convert the single allele value into a bialleic value for each value based on the major and minor allele columns (so if the allele for an individual is the major allele, I want to paste the minor allele after it with a space separator and vice versa). If the value is missing (N) I'd like to replace it with 0 0. The idea here is to format these data for Plink.</p>
  
  <p>So far I have tried to use the ifelse function but without success. Any suggestions as to how to get the biallelic values here? Thank you very much! I've included a made up data set in the formats I am referring to.</p>
  
  <p>What I have now:</p>
  
  <pre><code>rs#       major minor   ind1    ind2    ind3    ind4
  rs123456    A    G      A       A       A        G
  rs123457    G    C      C       G       C        G
  rs123458    C    G      C       C       G        C
  rs123459    T    A      A       T       N        T
  </code></pre>
  
  <p>What I would like to</p>
  
  <pre><code>rs        major minor   ind1    ind2    ind3    ind4
  rs123456    A    G      A G     A G     A G      G A
  rs123457    G    C      C G     G C     C G      G C
  rs123458    C    A      C A     C A     A C      C A
  rs123459    T    A      A T     T A     0 0      T A
  </code></pre>
  
  <p>Thanks!
  Rob</p>