>>>>> "HO" == Hong Ooi <[EMAIL PROTECTED]>
>>>>> on Thu, 21 Jun 2007 15:49:42 +1000 writes:
HO> R doesn't use the 'functionname = result' idiom to return a value from a
HO> function. It looks like you're after:
HO> aaa <- function(a)
HO> {
HO> if(a == 1) return(1)
HO> if(a != 1) return(2)
HO> }
HO> or
HO> aaa <- function(a)
HO> {
HO> if(a == 1) 1
HO> else 2
HO> }
HO> see ?return
or to continue the "Variations on a theme" :
aaa <- function(a) if(a == 1) 1 else 2
(You don't need "{" .. "}" :
some people argue you should
always use them for defensive programming
where I would not use them in simple "one liners",
but would use them otherwise
)
Martin Maechler, ETH Zurich
______________________________________________
[email protected] 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.