title: R - Get number of values per group without counting NAs
body: <p>So I'm trying to count the number of values per group in a column without counting the NAs.
  I've tried doing it with "length" but I can't figure out how to tell "length" to leave the NAs be, when in the context of looking at values per group.</p>
  
  <p>I've found similar problems but couldn't figure out how to apply the solutions to my case:</p>
  
  <p><a href="https://stackoverflow.com/questions/17500679/length-of-columns-excluding-na-in-r">Length of columns excluding NA in r</a></p>
  
  <p><a href="http://r.789695.n4.nabble.com/Length-of-vector-without-NA-s-td2552208.html" rel="nofollow noreferrer">http://r.789695.n4.nabble.com/Length-of-vector-without-NA-s-td2552208.html</a></p>
  
  <p>I've created a minimal working example to illustrate the problem:</p>
  
  <pre><code># making some data
  value &lt;- c(3,10,9,"NA",5,"NA","NA",4)
  group &lt;- c("A","A","B","C","B","A","A","C")
  
  example &lt;- data.frame(value, group)
  
  example
  #     value group
  # 1     3     A
  # 2    10     A
  # 3     9     B
  # 4    NA     C
  # 5     5     B
  # 6    NA     A
  # 7    NA     A
  # 8     4     C
  
  
  # trying to extract the number of values (without counting NAs) for each group
  n.example &lt;- tapply(example$value, list(example$group), length)
  n.example
  # A B C 
  # 4 2 2
  
  #Correct answer would be:
  # A B C 
  # 2 2 1  
  </code></pre>
  
  <p>I'd appreciate any kind of help!</p>
  
  <p>Thx,
  Carina</p>