Description Usage Arguments Details Value Examples
judge if an object is or not a falsy value. This includes:
empty value, empty string ""
, NULL
, NA
, length of 0 and FALSE
itself
1 2 3 4 5 | notFalsy(x)
isFalsy(x)
emptyIsFalse(x)
|
x |
any R object |
R does not have good built-in methods to judge falsy values and these kind
of values often cause errors in if
conditions, for example
if(NULL) 1 else 2
will cause error. So this function will be useful to
handle this kind of situations: if(notFalsy(NULL)) 1 else 2
.
not working on S4 class objects.
isFalsy
is the reverse of notFalsy
: isFalsy(x)
= !notFalsy(x)
emptyIsFalse
is the old name for notFalsy
Useful for if statement. Normal empty object in if will spawn error. Wrap the
expression with emptyIsFalse
can avoid this. See examples
NA
, ""
, NULL
, length(0)
, nchar == 0
and FALSE
will return
FALSE
, otherwise TRUE
in notFalsy
and the opposite in isFalsy
1 2 3 4 5 6 7 8 9 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.