Description Usage Arguments Reuse good code Alternative See Also
A Version of base::ifelse()
.
1 | IfElse(test, a, b)
|
test, a, b |
Equivalent to |
"The single biggest way to improve both the quality of your code and your productivity is to reuse good code (...) Many algorithms have already been invented, tested, discussed in the trade literature, reviewed, and improved".
–Code complete 2, by Steve McConnell.
A good alternative is dplyr::if_else()
: "Compared to the base ifelse(),
this function is more strict. It checks that true and false are the same
type. This strictness makes the output type more predictable, and makes it
somewhat faster".
base::if()
, base::ifelse()
, dplyr::if_else()
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.