title: Replacing character in data frame with number based on contional information in each row
body: <p>For the below data I would like to use the allele variable to recode the rest of the data, as following : 
  If  the first letter  in variable allele at specific row start with A  replace all  A with 1 for that row only. And if the row start with G in variable allele at specific row replace all  G with 1 for that row only. And if the row start with C  in variable allele at specific row start with T  replace all  T with 1 for that row only .  Then replace H with 0  ( in all the data frame) and the rest of the letters ( AGCT) with -1 for all the data frame.</p>
  
  <pre><code>    alleles x1  x2  x3  x4
  1   A/G G   G   G   G
  2   A/G G   G   G   G
  3   A/C C   N   N   C
  4   C/T T   N   N   T
  5   C/G N   C   C   H
  6   C/G C   N   N   C
  7   C/T C   C   T   C
  8   A/G G   G   A   G
  9   A/G N   N   A   A
  10  A/G G   G   N   G
  11  C/T N   C   C   C
  12  A/G N   A   A   A
  </code></pre>