From: Aaron J Mackey (ajm6q@virginia.edu)
Date: Wed 28 Nov 2001 - 04:38:00 EST
Message-id: <Pine.OSF.4.33.0111271231110.4432-100000@alpha10.bioch.virginia.edu>
On Tue, 27 Nov 2001, Thomas Lumley wrote:
> Actually, which.max already does break ties -- it finds the first maximum.
Sorry, what I meant was: if there are ties, I want to apply additional
logic to decide which is the right row to return (i.e. I may not want the
first row that has the maximum coverage). I may want to break ties by
finding the row with the minimal "percid" or some other calculated value.
I think it might end up looking something like this:
filter <- function(this.subset) {
best <- which(this.subset$coverage == max(this.subset$coverage))
best <- which(this.subset$percid[best] == min(this.subset$percid[best]))
# any additional logic to narrow down best to the absolute best row index
# now return the first best row:
this.subset[best[1], , drop=FALSE]
}
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
This archive was generated by hypermail 2.1.3 : Thu 17 Jan 2002 - 11:10:09 EST