title: aggregate columns in R
body: <p>I have a data frame as follows: 
   x1 ,x2, x3 are column's name</p>
  
  <pre><code>x1 x2 x3
  A  c  d
  A  e  f
  B  z  f
  B  z  f
  B  d  e
  </code></pre>
  
  <p>I want to count the number of column x2 and x3 according to x1 
  Such as following table: </p>
  
  <pre><code>   x1 x2 x3
      A  2  2
      B  2  2
  </code></pre>
  
  <p>I have tried as follows: 
  library(plyr)
  df3&lt;-count(df, "x1","x2",x3) 
  But it give me an error <code>Error in Summary.factor</code>
  And Also I have tried this Approach </p>
  
  <pre><code>library(dplyr)
      df %&gt;% select(x1,x2,x3)
       group_by(df$x1) %&gt;%
        mutate(unique_types = n_distinct(df$x2,df$x3))
  </code></pre>
  
  <p>But it does not work. </p>