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
>
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
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
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
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")
5 matches
Mail list logo