[R] Problem with parser and if/else

Brown, Simon simon.brown at metoffice.com
Thu Nov 13 13:39:03 CET 2003


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:
> source("test_if_else.R")
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:
> source("test_if_else2.R")
Error in parse(file, n, text, prompt) : syntax error on line 6
>

Could someone explain this to me please?

Thanks,

Simon.
-- 
Dr. Simon Brown                         Climate extremes research manager
simon.brown at metoffice.com                http://www.hadleycentre.com
Telephone: +44 (0)1392 886879             Fax: +44 (0)870 900 5050
Met Office Hadley Centre, FitzRoy Road, EXETER, EX1 3PB, U.K




More information about the R-help mailing list