Skip to content
Prev 257820 / 398502 Next

Removing row with smallest value, for a given factor

On 2011-04-23 07:02, David Winsemius wrote:
ave() is one of those really handy functions, but I think
that you meant

  dat[ !ave(dat$index, list(dat$day), FUN=function(x) x==min(x)), ]

Here's another way, using the plyr package

  require(plyr)
  ddply(dat, .(day), .fun = function(x) subset(x, index != min(index)))

Peter Ehlers