title: in scala how do we aggregate an Array to determine the count per Key and the percentage vs total
body: <p>I am trying to find an efficient way to find the following : </p>
  
  <ol>
  <li>Int1 = 1 or 0, Int2 = 1..k (where k = 3) and Double = 1.0 </li>
  <li>I want to find how many 1 or 0 are there in every k </li>
  <li>I need to find the percentage of result of 3 on the total of the size of the Array??</li>
  </ol>
  
  <p>Input is :</p>
  
  <pre><code>  val clusterAndLabel = sc.parallelize(Array((0, 0), (0, 0), (1, 0), (1, 1), (2, 1), (2, 1), (2, 0)))
  </code></pre>
  
  <p>So in this example: </p>
  
  <ol>
  <li>I have :   0,0 = 2 , 0,1 = 0  </li>
  <li>I have :   1,0 = 1 , 1,1 = 1</li>
  <li>I have :   2,1 = 2 , 2,0 = 1</li>
  </ol>
  
  <p>Total is 7 instances </p>
  
  <p>I was thinking of doing some aggegation but I am stuck on the thought that they are both considered 2-key join</p>