title: Counting number of elements in a character column by levels of a factor column in a dataframe
body: <p>I am a beginner in R. I have a dataframe in which there are two factor columns. One column is a company column, second is a product column. There are several missing values in product column and so I want to count the number of values in product column for each company (or each level of the company variable). I tried table, and count function in plyr package but they only seem to work with numeric variables. Please help!
  Lets say the data frame looks like this:</p>
  
  <pre><code>df &lt;- data.frame(company= c("A", "B", "C", "D", "A", "B", "C", "C", "D", "D"), product = c(1, 1, 2, 3, 4, 3, 3, NA, NA, NA))
  </code></pre>
  
  <p>So the output I am looking for is -</p>
  
  <p>A 2
  B 2
  C 3
  D 2</p>
  
  <p>Thanks in advance!!</p>