I have a dataframe, x, with over 60,000 rows that contains one Factor, "id", with 27 levels. The dataframe contains numerous continuous values (along column "diff") per day (column "date") for every level of id. I would like to select only one row per animal per day, i.e. that containing the minimum value of "diff", along the full length of 1:nrow(x). I am not yet able to conduct anything beyond the simplest of functions and I was hoping someone could suggest an effective way of producing this output.
e.g. given this input: id day diff 1 01-01-09 0.5 1 01-01-09 0.7 2 01-01-09 0.2 2 01-01-09 0.4 1 01-02-09 0.1 1 01-02-09 0.3 2 01-02-09 0.3 2 01-02-09 0.4 I would like to produce this output: id day diff 1 01-01-09 0.5 2 01-01-09 0.2 1 01-02-09 0.1 2 01-02-09 0.3 It doesn't seem extremely difficult but I'm sure there are easier ways than how I am currently approaching it! -- View this message in context: http://www.nabble.com/Subset-by-Factor-by-date-tp17835631p17835631.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.