Conditional statements in R always follow the logical scheme reproduced as follows:
if (condition){then execute} else {execute}
This scheme basically means that the instruction enclosed within the first brackets will be executed only in the case of the condition being true, while in the opposite case only the second set of instructions will be executed.
Within the R language it is, moreover possible to concatenate more than one conditional statement leveraging else if, like in the example below:
if(1>2){print("what a strange world")}else if(1==2){print("still in a strange world")}else{print("we landed in the normal world")}
Â