[R] how to find the location of the first TRUE of a logical vector
Jason Liao
jg_liao at yahoo.com
Thu Mar 6 03:42:31 CET 2003
Many thanks to all who replied: Marc Schwartz, Douglas Grove, Spencer
Graves, J.R. Lockwood, Roger Peng, Martina Pavlicova, Steve
Su,james.holtman, Wiener, Matthew, Domijan, Katarina and Douglas Bates.
Let x be the logical vector. The best solution seems to be:
which(x)[1].
Now my code is much simpler.
Jason
=====
Jason G. Liao, Ph.D.
Division of Biometrics
University of Medicine and Dentistry of New Jersey
335 George Street, Suite 2200
New Brunswick, NJ 08903-2688
phone (732) 235-8611, fax (732) 235-9777
http://www.geocities.com/jg_liao
More information about the R-help
mailing list