Hi Farnoosh, set.seed(25) Data.All.Var<- data.frame(ID= sample(LETTERS[1:10],25,replace=TRUE), value=rnorm(25),stringsAsFactors=FALSE)
set.seed(28) Y.Out<- data.frame(ID=sample(LETTERS[1:5],25,replace=TRUE),value=rnorm(25),stringsAsFactors=FALSE) unique(Y.Out$ID) #[1] "A" "C" "E" "D" "B" unique(Data.All.Var$ID) # [1] "E" "G" "B" "I" "J" "D" "A" "C" "F" "H" Data.All.Var$ID[!Data.All.Var$ID%in% Y.Out$ID] #[1] "G" "I" "J" "G" "J" "F" "G" "F" "H" "H" DataAllExclude<- Data.All.Var[!Data.All.Var$ID%in% Y.Out$ID,] DataAllExclude # ID value #2 G 0.23508558 #4 I -0.38736217 #6 J -0.24331815 #7 G -0.32137638 #13 J 0.57385268 #14 F 0.59750664 #15 G -0.01775669 #17 F 0.11683731 #18 H -1.11311883 #20 H 0.46184261 A.K. ________________________________ From: farnoosh sheikhi <farnoosh...@yahoo.com> To: "smartpink...@yahoo.com" <smartpink...@yahoo.com> Sent: Sunday, April 21, 2013 2:45 AM Subject: Excluding observations Hi Arun, I have a bit problem excluding some observations from the ID variable in the data. I really appreciate if you can help me. The values that I want to exclude are coming from: inter<-Data.All.Var$ID[Data.All.Var$ID%in%Y.Out$ID] inter<- as.character(inter) Exclude from the original data: DataAllExclude<-Data.All.Var$ID[-inter] or [!inter] ----> this code doesn't work! Thanks a lot. ______________________________________________ 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.