>> %<%  would extend the vocabulary established by %in%, and work in the same 
>> situations.
>> e.g. 
>> # only set “flynnEffect" for people known to be under 12, not for people 
>> where age is NA
>> twinData[twinData$Age %<% 12, "flynnEffect"] = FALSE 

>> Addressing Duncan's point about returning a logical array... the %<% 
>> function should be:
>> 
>> "%<%"<- function(table, x){
>>      lessThan = table<  x
>>      lessThan[is.na(lessThan)] = FALSE
>>      return(lessThan)
>> }
> 
> I think that still doesn't work quite right.  You want the conversion of NA 
> to FALSE to happen as the last
> part of evaluating an expression, not in intermediate steps.  Otherwise:
>        !(a %<% 10)
>  will give TRUE for NA values, which may not be as intended, if your 
> intention was to skip NA cases.

Yes, so that would be by design: just as  !(1 %in% NA) returns TRUE, whereas  
!(1 == NA).

______________________________________________
R-help@r-project.org 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.

Reply via email to