From maechler at stat.math.ethz.ch  Fri Sep 11 12:22:54 2009
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Fri, 11 Sep 2009 12:22:54 +0200
Subject: [Rd] Logic ("!", "&", ...) on complex
Message-ID: <19114.9470.797624.843607@lynne.math.ethz.ch>

The documentation,  help("!") e.g.,
contains

 > Arguments:

 >     x, y: logical vectors, or objects which can be coerced to such or
 >           for which methods have been written.

and then later

 > Numeric and complex vectors will be coerced to logical values,
 > with zero being false and all non-zero values being true. 

and that is consistent with what  S-plus (3.4, 5.1, 8.0.2)
gives.

However, (nowadays at least) R internally checks and gives an
error for complex arguments,
even though   as.logical(0 + 1i)  works fine.

 > z <- complex(i=1)
 > !z
 Error in !z : invalid argument type
 > !as.logical(z)
 [1] FALSE


I'm proposing to make R's behavior consistent with its
documentation and predecessor.

Martin Maechler



[Rd] Logic ("!", "&", ...) on complex
Martin Maechler