Rif | R If Statement - r - learn r - r programming
- test_expression: If the test_expression is TRUE, the statement gets executed. But if statement is FALSE, nothing will occur. And test_expression can be a logical or numeric vector, but only the first element is taken into consideration. In the case of numeric vector, zero is occupied as FALSE, rest as TRUE.
- Here we declare the variable x value as “5”.
- In this statement, we check the value for the variable x =5 is greater than 3 (5>3), because if the condition is true the prints "This is odd number” statement.
- Here the value of the variable “x” are greater than 3 so “if” condition will be satisfied and the output print statement will be executed.