Hello Andy

thanks for this; but


R> x <- 1:10
R> f
function(n) {
  if(is.null(n) || is.na(n) || abs(n) < pi) {
    return(FALSE)
  } else {
    return(TRUE)
  }
}
R> x <- 1:10
R> f(x[x>11])
Error in if (is.null(n) || is.na(n) || abs(n) < pi) { : 
        missing value where logical needed
> 






> 
> Try:
> 
> f <- function(n) {
>   if(is.null(n) || is.na(n) || abs(n) < pi) {
>     return(FALSE)
>   } else {
>     return(TRUE)
>   }
> }
> 
> Note that the order of the conditions inside if() matters: is.na(n) only
> gets evaluated if is.null(n) is FALSE, and so on.
> 
> Andy
> 


-- 

Robin Hankin, Lecturer,
School of Geography and Environmental Science
Tamaki Campus
Private Bag 92019 Auckland
New Zealand

[EMAIL PROTECTED]
tel 0064-9-373-7599 x6820; FAX 0064-9-373-7042

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

Reply via email to