title: convert 1 character string into numeric values
body: <p>I would like to convert a charter sequence into a numeric sequence.</p>
  
  <p>My variable is called labCancer and is made like this:</p>
  
  <pre><code>labCancer
  
  [1] M M M M M M M M M M M M M M M M M M M B B B M M M M M M M M M M M M M M M B
  </code></pre>
  
  <p>I would like to have:</p>
  
  <pre><code>[1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 0
  </code></pre>
  
  <p>I tried using</p>
  
  <pre><code>labCancer_2 &lt;- labCancer 
  
  for (i in 1:569)    {
    if (labCancer[i] == "M") {
      labCancer_2[i] &lt;- 1
    } else {
  
   labCancer_2[i] &lt;- 2
  
   } }    
  </code></pre>
  
  <p>but it doesn't work.</p>
  
  <p>Andrea</p>