which(a == .4)[1] b
On Jun 10, 2007, at 4:45 AM, gallon li wrote: > find the position of the first value who equals certain number in a > vector: > > Say a=c(0,0,0,0,0.2, 0.2, 0.4,0.4,0.5) > > i wish to return the index value in a for which the value in the > vector is > equal to 0.4 for the first time. in this case, it is 7. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@stat.math.ethz.ch 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. ______________________________________________ R-help@stat.math.ethz.ch 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.