IfElse: A Version of 'base::ifelse()'.

Description Usage Arguments Reuse good code Alternative See Also

Description

A Version of base::ifelse().

Usage

1
IfElse(test, a, b)

Arguments

test, a, b

Equivalent to test, yes, no in base::ifelse().

Reuse good code

"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.

Alternative

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".

See Also

base::if(), base::ifelse(), dplyr::if_else().


forestgeo/ctfs documentation built on May 3, 2019, 6:44 p.m.