On Fri, 11 Jul 2003 [EMAIL PROTECTED] wrote:

> Hi Folks,
>
> Example:
> t<-c(1,2,3,4,5,6,7,8,9)
> u<-c(1,NA,3,NA,5,NA,7,NA,9)
> t[u==5]
> --> NA NA 5 NA NA
>
> Now, if I could somehow set things so that "NA" was FALSE for
> indexing, then
> t[u==5]
> --> 5

t[u %in% 5]


> I know I can do it with
> t[(u==5)&(!is.na(u))]
> but in the situation I am dealing with this leads to massively
> cumbersome, typo-prone and hard-to-read code.
>
> Also, as an extra, it would be very useful if, for instance,
> t[u==NA] --> 2 4 6 8

t[ u %in% NA]


        -thomas

Thomas Lumley                   Assoc. Professor, Biostatistics
[EMAIL PROTECTED]       University of Washington, Seattle

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

Reply via email to