I want to write a function,Determine the input is equal to 1, but The input maybe includes (NA NULL).
> equals1 <- function(x){
+   return(x==1)
+ }
> equals1(1)
[1] TRUE
> equals1(Inf)
[1] FALSE
> equals1(NA)
[1] NA
> equals1(NULL)
logical(0)
> equals1(NaN)
[1] NA
I want is as follows:
equals1<-function(x){
   if(is.null(x)){
     return(FALSE)
     }else if(is.na(x)){
       return(FALSE)
     }else{return(x==1)}
}
c(equals1(1),equals1(Inf),equals1(NA),equals1(NULL),equals1(NaN))
# [1]  TRUE FALSE FALSE FALSE FALSE
Is there a simple function? Thanks!
 
     
    