[R] Got "Unexpected ELSE error"

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Wed Jun 20 11:54:26 CEST 2007


You need to put the else statement on the same line as the closing curly
bracket.

a <- TRUE
if ( a ){
        cat("TRUE","\n")
} else {
        cat("FALSE","\n")
}

Cheers,

Thierry

------------------------------------------------------------------------
----
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
Thierry.Onkelinx op inbo.be
www.inbo.be 

Do not put your faith in what statistics say until you have carefully
considered what they do not say.  ~William W. Watt
A statistical analysis, properly conducted, is a delicate dissection of
uncertainties, a surgery of suppositions. ~M.J.Moroney

 

> -----Oorspronkelijk bericht-----
> Van: r-help-bounces op stat.math.ethz.ch 
> [mailto:r-help-bounces op stat.math.ethz.ch] Namens Shiazy Fuzzy
> Verzonden: woensdag 20 juni 2007 11:41
> Aan: r-help op stat.math.ethz.ch
> Onderwerp: [R] Got "Unexpected ELSE error"
> 
> 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")
> }
> else
> {
>         cat("FALSE","\n")
> }
> 
> 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 op 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