From: Peter Dalgaard BSA (p.dalgaard@pubhealth.ku.dk)
Date: Wed 21 Feb 2001 - 09:08:09 EST
Message-ID: <x2ae7hhs12.fsf@blueberry.kubism.ku.dk>
Thomas Lumley <tlumley@u.washington.edu> writes:
> On Tue, 20 Feb 2001, Duncan Murdoch wrote:
> > x _ runif(100)
> > x[firstthat(x > 0.8)]
> >
>
> firstthat<-function(x) min(which(x))
>
> does roughly what you want. It returns integer infinity if
> there are no matches.
Um. The result of which() is sorted, so how about
firstthat<-function(x) which(x)[1]
(gives NA if no matches)
-- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 2b30 : Fri 22 Jun 2001 - 18:58:33 EST