[R] How can I return rows from a data frame with maximum value by factor?

Nick Ackerman nick.ackerman at pgn.com
Wed Mar 17 18:00:44 CET 2010


Hi,

I'm new to R and new to this forum. I'm struggling with trying to extract
certain rows of data from my data.frame. The data.frame has eleven columns.
Among those columns are "FISH_ID" and "DATE_TIME". FISH_ID is a factor. For
each of my 21 unique FISH_IDs (levels) I have a few to a few thousand rows,
each row with a unique DATE_TIME value. I would like to obtain, for each
FISH_ID, the entire record from the data.frame with the latest DATE_TIME
value (i.e. max (DATE_TIME). Thus, the resulting subset would be the
original eleven columns by 21 rows (one for each level of my FISH_ID). 

Any advice would be greatly appreciated.

Nick
-- 
View this message in context: http://n4.nabble.com/How-can-I-return-rows-from-a-data-frame-with-maximum-value-by-factor-tp1596777p1596777.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list