Bug 17218 - ?as.logical does not say what it does to numeric arg
Summary: ?as.logical does not say what it does to numeric arg
Alias: None
Product: R
Classification: Unclassified
Component: Documentation (show other bugs)
Version: R-devel (trunk)
Hardware: Other Linux
: P5 enhancement
Assignee: R-core
Depends on:
Reported: 2017-01-30 15:56 UTC by Charles J. Geyer
Modified: 2017-02-02 16:25 UTC (History)
1 user (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Charles J. Geyer 2017-01-30 15:56:59 UTC
The help page for as.logical does not say what it does to a numeric argument (it does say what it does to "factor" and "character").  Apparently it follows the way of C and C++ in converting zero to FALSE, non-zero to TRUE and NA or NaN to NA.  But the C code for this function is so complicated that I have not verified that.

Could some expert who is sure what as.logical does to numeric arg please fix the documentation?  Presumably what it does should go in the values section (like the descriptions already there of what it does to "factor" and "character").

BTW, I could not find this documented in any of the manuals either.
Comment 1 Martin Maechler 2017-02-02 16:25:07 UTC
?Logic  has the important part about it in its  "Details:"

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

OTOH, I did not find it in the R Language  manual (after non-exhaustive search).

Also mentioning it in ?as.logical  seems "logical" (and maybe a \link{Logic} ) there as well.