View source: R/missingValues.R
| ifElseMore | R Documentation |
ifelse() handling NA and NULL too.Tests a Boolean scalar value and returns one of four values:
If x is TRUE, returns the value of the true parameter (TRUE by default).
If x is FALSE, returns the value of false parameter (FALSE by default).
If x is NA, returns the value of na parameter (NA by default).
If x is NULL, returns the value of null parameter (NULL by default).
ifElseMore(x, true = TRUE, false = FALSE, na = NA, null = NULL)
x |
The value to test |
true |
The value to return if |
false |
The value to return if |
na |
The value to return if |
null |
The value to return if |
Depending on the value of x, returns the values of the matching
parameter true, false, na, or null.
ifElseMore( 3 > 2 )
#> [1] TRUE
ifElseMore( 3 < 2 )
#> [1] FALSE
ifElseMore( 3 < NA )
#> [1] NA
ifElseMore( 3 > 2, "it's True", "it's False", "it's NA", "it's Null" )
#> [1] "it's True"
ifElseMore( 2 > 3, "it's True", "it's False", "it's NA", "it's Null" )
#> [1] "it's False
ifElseMore( NA > 2, "it's True", "it's False", "it's NA", "it's Null" )
#> [1] "it's NA"
x <- NULL
ifElseMore( x )
#> [1] NULL
ifElseMore( x, "it's True", "it's False", "it's NA", "it's Null" )
#> [1] "it's Null"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.