Skip to content
Prev 40293 / 398498 Next

Problem with parser and if/else

Dear r-help people,

could you confirm that this is correct behaviour for R?  I am using RH9.

the code:
x1 <- 1:6
t1 <- 5
if (length(x1) >= t1) {
	cat("in the if \n")
} else {
	cat("in the else\n")
}

runs fine:
in the if
but the code:
x1 <- 1:6
t1 <- 5
if (length(x1) >= t1) {
	cat("in the if 2\n")
} 
else {
	cat("in the else\n")
}

fails with the error:
Error in parse(file, n, text, prompt) : syntax error on line 6
Could someone explain this to me please?

Thanks,

Simon.