[R] Re: R bug? (if-else problem in main program)
Anita Gulyasne Goldpergel
anitag at latte.harvard.edu
Wed Nov 6 20:22:12 CET 2002
Thank you very much everybody for your answers!
Before I wrote my message, I had tried to use
brackets. So I've discovered something, what can be
useful for everyone:
If I put the end-bracelet in different line from else,
it doesn't work:
if ( a == 1 ) {
print("yes")
}
else {
print("no")
}
But if I put it one line, as you wrote, like } else {
it works.
Thanks again,
Anita
Lorenz Gygax writes:
>
>
>> Example:
>> -------
>> a <- 1
>>
>> if ( a == 1 )
>> print("yes")
>> else
>> print("no")
>> --------
>
> If you want to split this over several lines, you need curly braces:
>
> a <- 1
>
> if ( a == 1 ) {
> print ('yes')
> } else {
> print ('no')
> }
>
> Cheers, Lorenz
>
>
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list