[R] Extracting subset of a vector

Peter Dalgaard p.dalgaard at biostat.ku.dk
Sat Oct 11 21:37:48 CEST 2008


Megh Dal wrote:
> I have 2 vecros :
> x<-c(100,96,88,100,100,96,80,68,92,96,88,92,68,84,84,88,72,88,72,88)
> x1 = sample(x, 5, replace=FALSE)
>
> Now i want to get remaining values of vector "x" those are not member of vector "x1". Can anyone please tell me how to do that?
>
>   
x[!(x %in% x1)]  should do it. (Had it not been for  the duplicates, 
setdiff(x,x1) should work too.)

-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907



More information about the R-help mailing list