The syntax of if-else
control structure in R is:
main.r131 chars6 lines
Here's an example of how to use if-else
:
main.r177 chars10 lines
Output:
main.r37 chars2 lines
In the above code, the condition x > 10
is evaluated. Since 5 is not greater than 10, the statements inside the else
block are executed, and the message "x is less than or equal to 10." is printed to the console.
gistlibby LogSnag