title: How can I separate a matrix into smaller ones in R?
body: <p>I have the following matrix</p>
  <pre><code>2    4    1
  6    32   1
  4    2    1
  5    3    2
  4    2    2
  </code></pre>
  <p>I want to make the following two matrices based on 3rd column</p>
  <p>first</p>
  <pre><code>2    4
  6    32
  4    2
  </code></pre>
  <p>second</p>
  <pre><code>5    3
  4    2
  </code></pre>
  <p>Best I can come up with, but I get an error</p>
  <blockquote>
  <p>x &lt;- cbind(mat[,1], mat[,2]) if mat[,3]=1</p>
  <p>y &lt;- cbind(mat[,1], mat[,2]) if mat[,3]=2</p>
  </blockquote>