title: How to select unique columns in an R matrix
body: <p>I want to select the unique columns in the matrix <code>six</code> on a simulation as follows:</p>
  
  <pre><code>&gt; set.seed(3)
  &gt; sam = replicate(100, sample(1:3, 4, rep = T))
  &gt; (six = sam[,colSums(sam)==6])
       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
  [1,]    2    1    1    1    1    1    1    1    2     1
  [2,]    2    2    3    1    1    2    2    1    2     2
  [3,]    1    1    1    1    2    1    1    3    1     1
  [4,]    1    2    1    3    2    2    2    1    1     2
  </code></pre>
  
  <p>I would like to end up with a matrix as:</p>
  
  <pre><code>     [,1] [,2] [,3] [,4] [,5]  [,6] 
  [1,]    2    1    1    1    1    1         
  [2,]    2    2    3    1    1    1       
  [3,]    1    1    1    1    2    3       
  [4,]    1    2    1    3    2    1        
  </code></pre>