I have noticed that an if-else condition does not work if else is on the next line, as follows. Isn't this bad?
i = 4;
if(i<5)
{
print("less than 5")
}
else
{
print ("greater than or equal to 5")
}
This can be corrected as follows
i = 4;
if(i<5)
{
print("less than 5")
}else
{
print ("greater than or equal to 5")
}
However, the same works(placing 'else' in the next line after 'if') if it's inside a for loop.
i = 0;
for(i in 1:10)
{
if(i<5)
{
print("less than 5")
}
else
{
print ("greater than or equal to 5")
}
}