title: Replace characters in a column with numbers R
body: <p>I have a matrix with last column contains characters:</p>
  
  <pre><code>A
  B
  B
  A
  ...
  </code></pre>
  
  <p>I would like to replace A with 1 and B with 2 in R. The expected result should be:</p>
  
  <pre><code>1
  2
  2
  1
  ...
  </code></pre>