The use of a conditional statement or conditional operator is an essential part of any programming task. You may need to test a scenario in which there are two alternative options. Further work will depend on the outcome of the test scenario. In R, using the if statement, you can compare scenarios that usually have two alternative options. In this recipe, you will use the conditional statement if.
The general structure of the if statement in R is as follows:
From the general structure of the if statement, it is intuitive that if the test scenario produces TRUE, then the statement with curly braces will be executed...