[R] The contrary of command %in%

Liaw, Andy andy_liaw at merck.com
Thu Apr 20 16:48:13 CEST 2006


Just negate the result of %in%; e.g.,

! a %in% b

Andy

From: Ghislain Vieilledent
> 
> Dear r-list,
> 
> I've got a data base:
> > HData[1:10,]
>    NumTree   Site Species Date Age DBH    H IdentTree
> 1        1 Queige  Spruce 2002 184  49 33.5  Queige 1
> 2        2 Queige     Fir 2002  NA   5  4.6  Queige 2
> 3        3 Queige     Fir 2002  25   8  6.6  Queige 3
> 4        4 Queige  Spruce 2002 198  47 32.5  Queige 4
> 5        5 Queige     Fir 2002 200  59 35.3  Queige 5
> 6        6 Queige  Spruce 2002  80  16  9.4  Queige 6
> 7        7 Queige     Fir 2002  NA   5  4.2  Queige 7
> 8        8 Queige     Fir 2002 200  44 32.5  Queige 8
> 9        9 Queige     Fir 2002  NA   5  3.4  Queige 9
> 10      10 Queige  Spruce 2002 167  48 32.8 Queige 10
> ...
> 
> I want to remove particular points determined by
> > HDataPartP<-HData[H<1.30,]
> and
> > HDataPartP2<-HData[H<8&DBH>20,]
> 
> That's why I want to use subset in a close form to: 
> HData2<-subset(HData,HData$H>1.30&HData$IdentTree
> "not"%in%HDataPartP2$IdentTree)
> 
> How should I do that ?
> Is there any R-syntax saying "not element of that object" ?
> 
> Thanks for your help.
> 
> Ghislain.
> 
> --
> Ghislain Vieilledent
> 06 24 62 65 07
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list 
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
>




More information about the R-help mailing list