title: How to create a variable and apply it to a column?
body: <p>This is kind of a two part question. I have a dataset that I am attempting to add select column together, but I also want to alter the data so it is a bit easier to add. Here is an example of my data set. The data set is called ChrData</p>
  
  <pre><code>ChrData
    Chr location sample1 sample2 sample3 sample4 sample5
  1 1 34234 ./. 0/1 1/1 0/1 0/0
  2 1 5677876 0/1 1/1 1/2 0/0 1/1
  3 1 75424 ./. ./. 1/1 0/1 0/0
  4 1 98654 1/1 0/1 1/1 0/0 0/0
  5 1 4534 1/1 0/1 ./. 0/0 2/2
  </code></pre>
  
  <p>So what I would like to do is set </p>
  
  <pre><code>./. = 0 
  0/0 = 0
  0/1 = 1
  1/2 = 1
  1/1 = 2
  2/2 = 2
  </code></pre>
  
  <p>And then add columns:</p>
  
  <pre><code>ChrData$sample1 + ChrData$sample2 + ChrData$sample4
  </code></pre>
  
  <p>and also:</p>
  
  <pre><code>ChrData$sample3 + ChrData$sample5 
  </code></pre>
  
  <p>and then create a two new columns with this data. I am just not sure how to get R to recognize the new variables and then apply them to each cell?</p>