Description Usage Arguments Value Note Examples
If this, then that
1 2 3 4 5 |
.x |
the object to test. If |
.p |
the predicate for testing. Defaut is |
.f |
a mapper or a function run if .p(.x) is TRUE |
.else |
a mapper or a function run if .p(.x) is not TRUE |
Depending on wether or not .p(.x) is TRUE, .f() or .else() is run.
If you want these function to return a value,
you need to wrap these values into a mapper / a function. E.g, to return
a vector, you'll need to write if_then(1, is.numeric, ~ "Yay")
.
1 2 3 | a <- if_then(1, is.numeric, ~ "Yay")
a <- if_not(1, is.character, ~ "Yay")
a <- if_else(.x = TRUE, .f = ~ "Yay", .else = ~ "Nay")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.