From: John Miyamoto (jmiyamot@u.washington.edu)
Date: Fri 20 Dec 2002 - 22:50:35 EST
Message-id: <Pine.A41.4.44.0212200343410.12680-100000@mead5.u.washington.edu>
Thanks for many prompt and useful comments. The question was: if x is
the vector
> x <- c( 2, NA, 1, 5, 3)
> x
[1] 2 NA 1 5 3
Then x == 5 yields
> x == 5
[1] FALSE NA FALSE TRUE FALSE
whereas what I want is
FALSE FALSE FALSE TRUE FALSE
#--------------
Matthew Dowle sent a simple solution:
> x
[1] 2 NA 1 5 3
> x==5 & !is.na(x)
[1] FALSE FALSE FALSE TRUE FALSE
Thanks also to Brian Ripley who suggested that I look at chapter 2 of
MASS4, and Eric Lecoutre who pointed out that the 'which' function could
be useful for this problem.
John Miyamoto
--------------------------------------------------------------------
John Miyamoto, Dept. of Psychology, Box 351525
University of Washington, Seattle, WA 98195-1525
Phone 206-543-0805, Fax 206-685-3157, Email jmiyamot@u.washington.edu
Homepage http://faculty.washington.edu/jmiyamot/
--------------------------------------------------------------------
______________________________________________
R-help@stat.math.ethz.ch mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help
This archive was generated by hypermail 2.1.3 : Tue 01 Jun 2004 - 09:31:59 EST