Re: [R] Problems with NA's

2007-11-20 Thread leffgh
somewhere I read that " !is.na(your_vector)" is better than "your_vector!=NA" . Thomas L Jones, PhD wrote: > > Difficulty handling NA's: > Assume that I have a numeric vector y. For simplicity, assume that it has > 10 > elements. Assume that the third element has the value NA. I give it the >

Re: [R] Problems with NA's

2007-11-20 Thread J. R. M. Hosking
Thomas L Jones, PhD wrote: > Difficulty handling NA's: > Assume that I have a numeric vector y. For simplicity, assume that it has 10 > elements. Assume that the third element has the value NA. I give it the > following: > NA_test <- function (){ > y <- numeric (10) > y [3] <- NA > if (y [3] != N

Re: [R] Problems with NA's

2007-11-19 Thread Moshe Olshansky
The problem is that if you do the following: x <- NA then x == NA returns NA (and not TRUE or even FALSE). Use is.na to test for NA (see ?is.na). --- "Thomas L Jones, PhD" <[EMAIL PROTECTED]> wrote: > Difficulty handling NA's: > Assume that I have a numeric vector y. For > simplicity, assume tha

Re: [R] Problems with NA's

2007-11-19 Thread Marc Schwartz
On Mon, 2007-11-19 at 22:18 -0500, Thomas L Jones, PhD wrote: > Difficulty handling NA's: > Assume that I have a numeric vector y. For simplicity, assume that it has 10 > elements. Assume that the third element has the value NA. I give it the > following: > NA_test <- function (){ > y <- numeric

[R] Problems with NA's

2007-11-19 Thread Thomas L Jones, PhD
Difficulty handling NA's: Assume that I have a numeric vector y. For simplicity, assume that it has 10 elements. Assume that the third element has the value NA. I give it the following: NA_test <- function (){ y <- numeric (10) y [3] <- NA if (y [3] != NA){(print ("no")} print ("Leaving NA_test")