Reputation: 381
I hope the question is not too foolish.
Is there a built-in R function that returns TRUE
when all the cases are FALSE
?
Similar to any()
or all()
but when, in the case of a logical vector of 2, TRUE
TRUE
returns FALSE
, TRUE
FALSE
returns FALSE
and FALSE
FALSE
returns TRUE
.
I would call it none()
.
Upvotes: 4
Views: 2126
Reputation: 84689
Negate(any)
?
> none <- Negate(any)
> none(c(TRUE,TRUE))
[1] FALSE
> none(c(TRUE,FALSE))
[1] FALSE
> none(c(FALSE,FALSE))
[1] TRUE
Upvotes: 3
Reputation: 12935
Or all
:
all(!vec)
Or using sum
:
sum(vec)==0
where vec
is your vector.
Upvotes: 1