Why do logical operators deny their argument when there is only one argument in R?

When passing only one vector to a logical and / or operator, the operator negates the argument:

> x = c(F,T,T) > `&`(x) [1] TRUE FALSE FALSE > `|`(x) [1] TRUE FALSE FALSE 

To make the logical operator work as idempotent, you need to pass one element vector as the second argument:

 > `&`(x,T) [1] FALSE TRUE TRUE > `|`(x,F) [1] FALSE TRUE TRUE 

Why do logical operators deny their argument when only one argument is passed?

+6
source share
1 answer

This has been modified in R 3.2.1 as a result of an error report . As you already noted, the previous behavior did not make any sense:

enter image description here

+7
source

Source: https://habr.com/ru/post/989438/


All Articles