I'm quit new to R programming. While I was trying to write my first if else statement I came across a weird behaviour which I don't understand.
When I run below code:
x = 4;
y=4;
if (x==y) {
print('they are equal');
} else {
print('they are not equal');
}
I get no error and I get the expected output. However when I change the indentation of the same exact code as below:
if(x==y){print('they are equal');}
else{print('they are not equal');}
I get an error message saying that 'Error: unexpected 'else' in "else"'.
So does this means that R is an indentation sensitive language like Python?
Aucun commentaire:
Enregistrer un commentaire