[R] inclusion criteria help
Thomas Lumley
tlumley at u.washington.edu
Tue Nov 27 20:24:45 CET 2001
On Tue, 27 Nov 2001, Aaron J Mackey wrote:
>
> 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]
> }
Yes, exactly like that, though you wouldn't need the drop=FALSE in this
context (it's harmless).
-thomas
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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 at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list