[R] "is.na(x) <- TRUE" versus "x <- NA" (was: Beginner's query - segmentation fault)

Duncan Murdoch dmurdoch at pair.com
Tue Oct 7 15:28:58 CEST 2003


On Tue, 07 Oct 2003 14:37:26 +0200, Uwe Ligges
<ligges at statistik.uni-dortmund.de> wrote :

>2. Use "is.na(x) <- TRUE" instead of "x <- NA":
>   is.na(temp[temp[ ,"t1"] == -999.00, "t1"]) <- TRUE

I hadn't heard this advice before.  The online help ?is.na gives this
cryptic advice:

     Function 'is.na<-' may provide a safer way to set missingness. It
     behaves differently for factors, for example.

I assume it means "safer than assigning NA", and "differently than
assigning NA", but how exactly is it safer, and how is it different?

Duncan




More information about the R-help mailing list