Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a built-in function "none"?

Tags:

function

r

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().

like image 232
have fun Avatar asked Oct 15 '25 23:10

have fun


2 Answers

We can use ! with any

!any(c(FALSE, FALSE))
like image 134
akrun Avatar answered Oct 18 '25 16:10

akrun


Negate(any) ?

> none <- Negate(any)
> none(c(TRUE,TRUE))
[1] FALSE
> none(c(TRUE,FALSE))
[1] FALSE
> none(c(FALSE,FALSE))
[1] TRUE
like image 27
Stéphane Laurent Avatar answered Oct 18 '25 14:10

Stéphane Laurent



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!