title: R count values per type
body: <p>My question  is related to this one from 2013 <a href="https://stackoverflow.com/questions/16159253/r-count-unique-values-by-category">R: Count unique values by category</a></p>
  
  <p>using the following data in <strong>R</strong>:</p>
  
  <pre><code>    set.seed(1)
  mydf &lt;- data.frame(
    Cnty = rep(c("185", "31", "189"), times = c(5, 3, 2)),
    Yr = c(rep(c("1999", "2000"), times = c(3, 2)), 
           "1999", "1999", "2000", "2000", "2000"),
    Plt = "20001",
    Spp = sample(c("Bitternut", "Pignut", "WO"), 10, replace = TRUE),
    DBH = runif(10, 0, 15)
  )
  
  mydf
  #    Cnty   Yr   Plt       Spp       DBH
  # 1   185 1999 20001 Bitternut  3.089619
  # 2   185 1999 20001    Pignut  2.648351
  # 3   185 1999 20001    Pignut 10.305343
  # 4   185 2000 20001        WO  5.761556
  # 5   185 2000 20001 Bitternut 11.547621
  # 6    31 1999 20001        WO  7.465489
  # 7    31 1999 20001        WO 10.764278
  # 8    31 2000 20001    Pignut 14.878591
  # 9   189 2000 20001    Pignut  5.700528
  # 10  189 2000 20001 Bitternut 11.661678
  </code></pre>
  
  <p>What i'd like to be able to do and what was not done by the previous asker or answerers is:</p>
  
  <p>Count how many counties each species exists in, which is very simply done with a table function</p>
  
  <p>However, in my data there are over a million rows five different species and I don't know how many counties (a very large number anyway)</p>
  
  <p>How could I get a table that gives me an answer of:</p>
  
  <pre><code>Species count_of_Counties
  bitternut 2
  pignut 3
  WO 2
  </code></pre>
  
  <p>instead of the following answer:</p>
  
  <pre><code>        Cnty
  # Spp         185 189 31
  #   Bitternut   2   1  0
  #   Pignut      2   1  1
  #   WO          1   0  2
  </code></pre>
  
  <p>If I attempt this solution I will have well over 400,000 columns </p>