From rich.fitzjohn at gmail.com  Thu Oct 20 02:43:02 2005
From: rich.fitzjohn at gmail.com (Rich FitzJohn)
Date: Thu, 20 Oct 2005 13:43:02 +1300
Subject: [Rd] is.na<- problem
In-Reply-To: <XFMail.051020011342.Ted.Harding@nessie.mcc.ac.uk>
References: <971536df0510191629q29acd508n5b2d488e8e3d8290@mail.gmail.com>
	<XFMail.051020011342.Ted.Harding@nessie.mcc.ac.uk>
Message-ID: <5934ae570510191743l54f7028fn6f38c3b66bedcab3@mail.gmail.com>

Hi,

It does seem to be working as advertised, but not particulary
intuitively.  From ?is.na

  The generic function 'is.na<-' sets elements to 'NA'

In fact:
xx <- c(NA, 1)
is.na(xx) <- 2
xx
[1] NA NA

or is.na(xx) <- 5
[1] NA  1 NA NA NA

Looks like this was introduced in 1.4.0; from NEWS:
    o	New generic function is.na<-(), from S4.  This is by default
	equivalent to x[value] <- NA but may differ, e.g. for factors
	where "NA" is a level.

Cheers,
Rich

On 10/20/05, Ted Harding <Ted.Harding at nessie.mcc.ac.uk> wrote:
> On 19-Oct-05 Gabor Grothendieck wrote:
> > In the following the first element of xx should have
> > been set to 0 but remains NA.  Any comments?
> >
> >> xx <- c(NA,1)
> >> is.na(xx) <- 0
> >> xx
> > [1] NA  1
> >> R.version.string # Windows XP
> > [1] "R version 2.2.0, 2005-09-20"
>
> I wonder, has it ever worked? I get the same as you on
>
> R.version.string #Linux
> [1] "R version 1.6.2, 2003-01-10"
>
> R.version.string #Linux
> [1] "R version 1.8.0, 2003-10-08"
>
> R.version.string #Linux
> [1] "R version 2.1.0, 2005-04-08"
>
> with the exception of
>
> R.version.string #Linux
> [1] "R version 1.2.3, 2001-04-26"
>
> which does know about is.na()<- at all.
>
>
> Hmmm
> Ted.
>
>
>
>
>
>
> --------------------------------------------------------------------
> E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
> Fax-to-email: +44 (0)870 094 0861
> Date: 20-Oct-05                                       Time: 01:11:45
> ------------------------------ XFMail ------------------------------
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>


--
Rich FitzJohn
rich.fitzjohn <at> gmail.com   |    http://homepages.paradise.net.nz/richa183
                      You are in a maze of twisty little functions, all alike



[Rd] is.na<- problem
Rich FitzJohn