I WAS GIVEN ANSWER: THE if's closing BRACKET should be BEFORE ELSE not ABOVE.
This error had already been discussed here: Error: unexpected '}' in " }" and https://stackoverflow.com/questions/15303559/error-unexpected-in But they do not help me.
I run the code:
i <- 21
if(i==22){
print(c("xxx"))
}
else{
print(c("yyy"))
}
And get an error
else{ Error: unexpected 'else' in "else"
print(c("yyy")) [1] "yyy" } Error: unexpected '}' in "}"
I use Rstudio on Windows, quite new R version and Rstudio, but not sure where to check it