In the if statement, the inner code is executed when the condition is true. The code which is outside the if block will be executed when the if condition is false.
There is another type of decision-making statement known as the if-else statement. An if-else statement is the if statement followed by an else statement. An if-else statement, else statement will be executed when the boolean expression will false. In simple words, If a Boolean expression will have true value, then the if block gets executed otherwise, the else block will get executed.
R programming treats any non-zero and non-null values as true, and if the value is either zero or null, then it treats them as false.
The basic syntax of If-else statement is as follows: