[R] logical and NA

Thomas Lumley tlumley at u.washington.edu
Wed Sep 4 16:46:55 CEST 2002


On Wed, 4 Sep 2002, Christian Hoffmann wrote:

> Hi there, (sorry Martin, ich habe den falschen Empfaenger erwischt :-(  )
>
> Is there a function in the base package or elsewhere which returns TRUE and
> not NA, even if NA is involved: (I did not find in the help system :-(  )
>
> if ( x==something & !is.na(something))
>
> or
>
> if ( x==something & !is.na(x==something))
>

x %in% something
is TRUE if x is an element of something and FALSE otherwise, so your first
example could be
   if (x %in% something)

	-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