R Else If | R If elseif else Statement - r - learn r - r programming
- In R programming, if statement can be followed by an optional else if...else statement, which is very suitable to test several conditions using single if...else if statement.
- In general, Else If statement works like the if condition works if the condition is true, if condition is false the else condition works, certainly further on if the else condition is false once again the else condition will be executed.
- Here we declare the variable x value as “5”.
- Here is the “if-elseif-else” statement where, the If condition executes the statements based on the true and false condition.Similarly, if the condition is false it executes the other elseif&if statements.
- Here in this output we get the “x” value as “5” and,where the elsecondition section will be satisfied so the output will be displayed as “The value is Zero”.