R if Statement
The if statement consists of the Boolean expressions followed by one or more statements. The if statement is the simplest decision-making statement which helps us to take a decision on the basis of the condition.
The if statement is a conditional programming statement which performs the function and displays the information if it is proved true.
The block of code inside the if statement will be executed only when the boolean expression evaluates to be true. If the statement evaluates false, then the code which is mentioned after the condition will run.
The syntax of if statement in R is as follows:
Let see some examples to understand how if statements work and perform a certain task in R.