On Tuesday 11 February 2003 04:40 pm, [EMAIL PROTECTED] wrote:
> I have what is likely to be a simple question about the else keyword.
>
> The usage in the help pages is as follows:
>
>       if(cond) cons.expr  else  alt.expr
>
> I would expect to be able to use it in the following way as well:
>
>       if(cond){
>               cons.expr
>       }
>       else alt.expr
>
> This results a syntax error.


What makes you say it does not work ? For example,


> foo = function(x) {
+    if (x == 1) {
+        print("one")
+    }
+    else {
+        print(x)
+    }
+  }
> 
> foo(1)
[1] "one"
> foo(2)
[1] 2
>

______________________________________________
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to