title: Counting unique values based on two columns with repeated rows, R data frame
body: <p>I have an R data frame with the following format:</p>
  
  <pre><code>column1    column2
  NA         NA
  1          A
  1          A
  1          A
  NA         NA
  NA         NA
  2          B
  2          B
  NA         NA
  NA         NA
  3          A
  3          A
  3          A
  
  df = structure(list(column1 = c(NA, 1L, 1L, 1L, NA, NA, 2L, 2L, NA, 
  NA, 3L, 3L, 3L), column2 = c(NA, "A", "A", "A", NA, NA, "B", 
  "B", NA, NA, "A", "A", "A")), .Names = c("column1", "column2"
  ), row.names = c(NA, -13L), class = "data.frame")
  </code></pre>
  
  <p>If the row in one column has an <code>NA</code>, the other column has an <code>NA</code>. 
  The numerical value in <code>column1</code> describes a unique group, e.g. rows 2-4 have the group <code>1</code>. The column <code>column2</code> describes the identity of this grouping. In this data frame, the identity is either <code>A</code>, <code>B</code>, <code>C</code>, or <code>D</code>. </p>
  
  <p>My goal is to tally the number of identities by group within the entire data frame: how many A groups there are, how many B groups, etc. </p>
  
  <p>The correct output for this file (so far) is there are 2 A groups and 1 B group. </p>
  
  <p>How would I calculate this? </p>
  
  <p>At the moment, I would try something like this:</p>
  
  <pre><code>length(df[df$column2 == "B"]) ## outputs 2 
  </code></pre>
  
  <p>but this is incorrect. If I combined <code>column1</code> and <code>column2</code>, took only unique values 1A, 2B, 3A, I guess I could count how many times each label from <code>column2</code> occurs? </p>
  
  <p>(If it's easier, I'm happy to use <code>data.table</code> for this task.)</p>