[R] Removing rows with earlier dates

Joshua Wiley jwiley.psych at gmail.com
Fri Dec 24 20:43:39 CET 2010


> with(YourDataFrame, tapply(`Effective Date`, `RULE COLUMNS`,
>  function(x) x[which.max(x)]))

David pointed out that this will just return a table of dates.  One
work around is:

do.call("rbind", by(DataFrame, DataFrame[, "RULE COLUMNS"],
  function(x) x[which.max(x[, "Effective Date"]), ]))

but that is not very simple or elegant, and both David's and Bill's
options seem superior.

Josh



More information about the R-help mailing list