title: Separate table/matrix for separate value of variable in R
body: <p>Suppose I have a data frame</p>
  
  <pre><code>   Id Name Price sales Profit Month Category Mode Supplier
  1   1    A     2     5      8     1        X    K     John
  2   1    A     2     6      9     2        X    K     John
  3   1    A     2     5      8     3        X    K     John
  4   2    B     2     4      6     1        X    L      Sam
  5   2    B     2     3      4     2        X    L      Sam
  6   2    B     2     5      7     3        X    L      Sam
  7   3    C     2     5     11     1        X    M     John
  8   3    C     2     5     11     2        X    L     John
  9   3    C     2     5     11     3        X    K     John
  10  4    D     2     8     10     1        Y    M     John
  11  4    D     2     8     10     2        Y    K     John
  12  4    D     2     5      7     3        Y    K     John
  13  5    E     2     5      9     1        Y    M      Sam
  14  5    E     2     5      9     2        Y    L      Sam
  15  5    E     2     5      9     3        Y    M      Sam
  16  6    F     2     4      7     1        Z    M     Kyle
  17  6    F     2     5      8     2        Z    L     Kyle
  18  6    F     2     5      8     3        Z    M     Kyle
  </code></pre>
  
  <p>I want to use <code>xtabs</code>, <code>tapply</code>, <code>table</code> or any other function which will give me table for each different category <code>X,Y,Z</code> ( so 3 tables) separately. Each table will be supplier vs Mode (i.e for each supplier how many different products were present there)
  It will look somewhat like this.</p>
  
  <pre><code>Category X
  
              Mode
      Supplier      K      L      M
         John       4      1      1
         Sam        0      3      0
         Kyle       0      0      0    
  
  Category Y
  
              Mode
      Supplier      K      L      M
         John       2      0      1
         Sam        0      1      2
         Kyle       0      0      0   
  
  
  Category Z
  </code></pre>
  
  <p>and so on. </p>
  
  <pre><code>table(df$Supplier,df$Mode)
  </code></pre>
  
  <p>gives number of times a supplier has been used under which mode but it doesn't gives 3 tables, it combines all together. So what I can do to have 3 separate tables instead of just one combined?</p>