From tlumley@u.washington.edu  Wed Jan 29 01:23:02 2003
From: tlumley@u.washington.edu (Thomas Lumley)
Date: Wed Jan 29 01:23:02 2003
Subject: [Rd] The function 'any' (PR#2503)
In-Reply-To: <200301290009.BAA23221@pubhealth.ku.dk>
Message-ID: <Pine.A41.4.44.0301281615080.157244-100000@homer04.u.washington.edu>

On Wed, 29 Jan 2003 louisept@pweh.com wrote:

> Full_Name: Paul Louisell
> Version: 1.6.2
> OS: Windows NT
> Submission from: (NULL) (192.249.47.9)
>
>
> There is a slight bug in the function 'any'. Given a logical vector (possibly
> including values of 'NA'), the default action of any should be as follows:
>
> (i) at least one value = T should return T
> (ii) NO values = T
>      (a) at least one value = 'NA' should return 'NA'
>      (b) all values = F should return F
>
> The problem is that the default action of 'any' is using the following rule:
>
> (i) at least one value = 'NA' returns 'NA'
> (ii) NO values = 'NA'
>      (a) at least one value = T returns T
>      (b) all values = F returns F
>

Yes, and the wrong logic is sitting there clearly in logic.c

    if (PRIMVAL(op) == 1) {	/* ALL */
	LOGICAL(s)[0] = haveNA ? NA_LOGICAL : !haveFalse;
    } else {			/* ANY */
	LOGICAL(s)[0] = haveNA ? NA_LOGICAL : haveTrue;
    }

Should be easy to fix.

	-thomas



[Rd] The function 'any' (PR#2503)
Thomas Lumley