According to what I've learned, the standard approach to write a "if - else if" sentence is as follows:
If (2==1), print("1"), else if (2==2), print("2"), otherwise print("3")
or
if (2==1) print("1") else print("2") if (2==2) print("2") else print ("3")
Quite the opposite, If I continue to write in this manner,
if (2==1) print("1") otherwise (print("3") or this way: if (2==2) print("2") else (print("3")
The statement does not work if (2==1) print("1") otherwise if (2==2) print("2") else print("3") Can you explain why else or else must come before else or else if they're on the same line? Is there any way to write the if-else if-else sentence in R without using brackets?