Chapter 7 Multiple condition decisions
While simple if
and if else
operations tests single conditions, we can make more complex operations, which tests multiple conditions.
With the ifelse()
function, we can test a test a vector of conditions and/or apply functions only under certain conditions. See the examples below:
## [1] "no" "no" "no" "no"
## [5] "no" "yes" "yes" "yes"
## [9] "yes" "yes"
While the if()
and if()
else
statements leave you with exactly two options, nested if()
else
statement allows you consider more alternatives.