title: R select from data frame: by date with repeated factors
body: <p>I have a data frame of addresses and dates of sale. There are multiple entries of some addresses. I want a new data frame that has each address only once and for that address to be selected by the most recent date. Here is a snippet of the data frame.</p>
  
  <pre><code>df &lt;-structure(list(address = c("2", "316", "647", "6904", "# 5 BENT TREE DR", "# 62 62000 E 440 PL", "# 7 BENT TREE DR", "#1 ARROWHEAD RD", "#1 ECHO DR", "#1 JACKS HIDEAWAY", "#1 JACKS HIDEAWAY", "#1 MARINA DR", "#1 WHITE CHAPEL", "#10 JACKS HIDEAWAY", "#10 PRIVATEER", "#10 SUMMERSIDE", "#102 THE MOORS", "#103 MOORS VIEW", "#108 THE MOORS", "#111 THE MOORS", "#112 THE MOORS", "#116 THE MOORS", "#12 DOGWOOD HOLLOW", "#12 MAINSTAY", "#120 THE MOORS", "#13 DOGWOOD HOLLOW", "#13 MEGHAN COVES", "#14 BEACON HILL", "#14 GRAND JEST", "#14 GRAND JEST"), sold = structure(c(13521, 11373, 13413, 14372, 15044, 14056, 15044, 12712, 12671, 12524, 11071, 11856, 11670, 11754, 12251, 11829, 11465, 12600, 11271, 11624, 11831, 11276, 12724, 14040, 11100, 12678, 12174, 12293, 14546, 11430), class = "Date")), .Names = c("address", "sold"), class = "data.frame", row.names = c(NA, 30L))
  df
  </code></pre>
  
  <p>For example, if</p>
  
  <pre><code>address       date
  123 Main St   2002-03-01 
  123 Main St   2005-01-01
  </code></pre>
  
  <p>I just want the 2005 dated line for 123 Main St in the new data frame. </p>
  
  <p>I tried some functions from <code>dplyr</code></p>
  
  <pre><code>library(plyr)
  library(dplyr)
  
  &gt; df %&gt;% group_by(address) %&gt;% max(df$sold)
  Error in FUN(X[[i]], ...) : 
    only defined on a data frame with all numeric variables
  &gt; df %&gt;% group_by(address) %&gt;% max(as.numeric(.(sold)))
  Error in function_list[[k]](value) : 
    (list) object cannot be coerced to type 'double'
  
  &gt; ddply(df, .(address), max(.(sold)))
  Error in max(.(sold)) : invalid 'type' (list) of argument
  </code></pre>
  
  <p>I don't know what to do from here and would appreciate help to come up with a way to select for a new data frame. </p>