@sarah,

it's true , but I need a boolean vector.


@berend

good idea


@David,

yes %in% work fine but I need > < <= and >=

@bill

yes, it could be a solution, but i prefer  a "simple" operator.. so i will
build one.


thank you all


2012/10/30 Sarah Goslee <sarah.goslee@gmail.com>

> Here's one option:
> >  vec<-c(3,4,5,NA,1,NA,9,NA,1)
> > subset(vec, vec > 2)
> [1] 3 4 5 9
> > subset(vec, vec == 1)
> [1] 1 1
>
> Sarah
>
> On Tue, Oct 30, 2012 at 5:08 PM, vincent guyader
> <vincent.guyader@gmail.com> wrote:
> > Hi everyone,
> >
> >  i'm looking for a "NA-friendly" operator
> >
> > I explain :
> >
> >         vec<-c(3,4,5,NA,1,NA,9,NA,1)
> >
> >         vec[vec == 1]  # NA  1 NA NA  1
> >
> > I dont want the NA's :
> >         vec[vec == 1 & ! is.na(vec)]# 1  1
> > is the same as
> >         vec[vec %in% 1] # 1  1
> >
> > %in% is NA-friendly :)
> >
> > But if i want >2 without the NA's :
> >
> >         vec[vec>2] #3  4  5 NA NA  9 NA
> >
> > if i dont want the NA i have to do :
> >
> >         vec[vec>2 & !is.na(vec)] #3  4  5  9
> >
> > is there an opérator to directly do that?
> >
> > any idea?
> >
> > thx a lot.
> >
>
>
> --
> Sarah Goslee
> http://www.functionaldiversity.org
>

	[[alternative HTML version deleted]]


