hadley / r4ds

R for data science: a book
http://r4ds.hadley.nz
Other
4.59k stars 4.22k forks source link

12.4.1 on `any()` and `all()` #1603

Open lhdjung opened 12 months ago

lhdjung commented 12 months ago

Section 12.4.1, "Logical summaries", says the following about any() and all():

Like all summary functions, they'll return NA if there are any missing values present [...].

This doesn't seem right because any instance of TRUE or FALSE, respectively, will make these functions return non-NA values, even if NA elements are present. This behavior follows from any() and all()'s relationship to the binary logical operators, as explained in the same paragraph.

any(TRUE, NA)
#> [1] TRUE
all(FALSE, NA)
#> [1] FALSE

TRUE | NA
#> [1] TRUE
FALSE & NA
#> [1] FALSE

Created on 2023-11-27 with reprex v2.0.2