From maechler at stat.math.ethz.ch  Mon Aug 15 11:07:43 2016
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Mon, 15 Aug 2016 11:07:43 +0200
Subject: [Rd] table(exclude = NULL) always includes NA
In-Reply-To: <540967018.14196661.1471146128783.JavaMail.yahoo@mail.yahoo.com>
References: <540967018.14196661.1471146128783.JavaMail.yahoo.ref@mail.yahoo.com>
	<540967018.14196661.1471146128783.JavaMail.yahoo@mail.yahoo.com>
Message-ID: <22449.34399.349376.938875@stat.math.ethz.ch>

>>>>> Suharto Anggono Suharto Anggono <suharto_anggono at yahoo.com>
>>>>>     on Sun, 14 Aug 2016 03:42:08 +0000 writes:

    > useNA <- if (missing(useNA) && !missing(exclude) && !(NA %in% exclude)) "ifany"
    > An example where it change 'table' result for non-factor input, from https://stat.ethz.ch/pipermail/r-help/2005-April/069053.html :

    > x <- c(1,2,3,3,NA)
    > table(as.integer(x), exclude=NaN)

    > I bring the example up, in case that the change in result is not intended.

Thanks a lot, Suharto.

To me, the example is convincing that the change (I commited
Friday), svn rev 71087 & 71088,   are a clear improvement:

(As you surely know, but not all the other readers:)
Before the change, the above example gave *different* results
for  'x'  and  'as.integer(x)', the integer case *not* counting the NAs,
whereas with the change in effect, they are the same:

> x <- as.integer(dx <- c(1,2,3,3,NA))
> table(x, exclude=NaN); table(dx, exclude=NaN)
x
   1    2    3 <NA> 
   1    1    2    1 
dx
   1    2    3 <NA> 
   1    1    2    1 
> 

--
But the change has affected 6-8 (of the 8000+) CRAN packages
which I am investigating now and probably will be in contact with the
package maintainers after that.

Martin



[Rd] table(exclude = NULL) always includes NA
Martin Maechler