Re: [R] Extract complete rows by group and maximum

2011-04-28 Thread Dimitris Rizopoulos
two possibilities are: f <- factor(DF$cvd_basestudy, unique(DF$cvd_basestudy)) ind <- ave(DF$es_time, f, FUN = function (x) x == max(x)) DF[as.logical(ind), ] f <- factor(DF$cvd_basestudy, unique(DF$cvd_basestudy)) lis <- lapply(split(DF, f), function (d) d[which.max(d$es_time), ]) do.call(rbind

[R] Extract complete rows by group and maximum

2011-04-28 Thread Sandy Small
Hi I'm trying to extract complete rows from a dataframe by group based on the maximum in a column within that group. Thus I have a dataframe: cvd_basestudy ... es_time ... _ study1... 0.3091667 study2... 0.3091667 study2... 0.2625000 study3... 0.30