[R] Re: "is.na(x) <- TRUE" versus "x <- NA"
Uwe Ligges
ligges at statistik.uni-dortmund.de
Tue Oct 7 16:11:49 CEST 2003
Duncan Murdoch wrote:
> 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?
Hmmmm. I was sure I had constructed an problematic example for a course
I hold last year in Dortmund, but I cannot find it again. Maybe
something for NA assignmets (into character vectors, I remember?) has
been fixed in the meantime.
Anyway, I have had the experience that there are cases, where "is.na(x)
<- TRUE" is the more secure way of doing it.
Additionally, it's mentioned in ?NA and in "S Programming", for example.
Uwe
More information about the R-help
mailing list