What is wrong with this if-else in my R program?
if(is.na(result)[1]) print("NA") else coef(result)[[1]]
I get an error message:
> if(is.na(result)[1]) + print("NA") > else Error: unexpected 'else' in "else" > coef(result)[[1]]
So, I added braces around if and else, and now I get this error:
> if(is.na(result)[1]) { + print("NA") Error: unexpected input in: "if(is.na(result)[1]) { ¬" > } else { Error: unexpected '}' in "}" > coef(result)[[1]] Error: unexpected input in "¬" > } Error: unexpected '}' in "}"
source share