title: scala count groupBy results
body: <p>I am a newbie to Scala, and I have the following question:</p>
  
  <p>Say I have parsed in a text file with the following format:</p>
  
  <pre><code>RDD:[A , Apple, a fruit]
      [A , America, a country]
      [A , Africa, a continent]
      [B , Brazil, a country]
  </code></pre>
  
  <p>and I want to <code>groupBy</code> the alphabet sso that I have something like:</p>
  
  <pre><code>[A, Apple, a fruit, America, a country, Africa a continent]
  </code></pre>
  
  <p>I then want to take this and <code>groupBy</code> itself so that it gives me the string, and the count for each letter:</p>
  
  <pre><code>[A, a, 3
      fruit, 1
      America, 1
      Africa, 1]
  </code></pre>
  
  <p>so far my code looks like this:</p>
  
  <pre><code>val joined = parsed.groupBy(_._2).map((x)=&gt;(x._1,x._2.map((y)=&gt; y._1).toSeq))
  val listtext = joined.map(x =&gt; x._2)
  val idfs = listtext.groupBy(l =&gt; l).map(t =&gt; (t._1, t._2.size))
  </code></pre>
  
  <p>but the result is wrong, it seems to take <code>listtext</code> as one string, which results in the count always being 1. </p>