[R] Got "Unexpected ELSE error"
Uwe Ligges
ligges at statistik.uni-dortmund.de
Wed Jun 20 11:52:14 CEST 2007
Shiazy Fuzzy wrote:
> Dear R-users,
>
> I have a problem with the IF-ELSE syntax.
> Please look at the folllowing code and tell me what's wrong:
>
> a <- TRUE
> if ( a )
> {
> cat("TRUE","\n")
> }
At this point, the expression above is complete and it ios evaluated if
called interactively.
Then, the code below is invalid (there is nothing that starts with "else").
> else
> {
> cat("FALSE","\n")
> }
Instead, use:
a <- TRUE
if ( a )
{
cat("TRUE","\n")
} else
{
cat("FALSE","\n")
}
Uwe Ligges
> If I try to execute with R I get:
> Error: syntax error, unexpected ELSE in "else"
> The strange thing is either "cat" instructions are executed!!
>
> My system is: Fedora Core 6 x86_64 + R 2.5.0 (rpm)
>
> Thank you very much in advance!!!!
>
> Regards,
>
> -- Marco
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list