[R] Subsetting for unwanted values

LCOG1 jroll at lcog.org
Fri Jun 4 01:52:10 CEST 2010


Hi all, 
   I have toyed with this for too long today and in the past i used multiple
lines of code to get at what i want.  Consider the following:

All i need to do is subset Pc to the values that do not equal Pc.X.  The
first attempt doesnt work because i have unequal lengths.  The second
attempt doesnt give me an the right answer.  


Pc<-c("Res","Com","Ind","Os","Mix","Gov","Rur")
Pc.X<-c("Com","Ind","Mix")
 PcToAdd_<-Pc[Pc!=Pc.X]
#Doesnt Work
AND

 PcToAdd_<-subset(Pc.X,Pc.X %in% Pc)
#Works but doesnt get me what i want

I am looking a return of PcToAdd_ <- "Res"  "Os" "Gov" "Rur"

This has got to be a simple answer.  Thanks  
-- 
View this message in context: http://r.789695.n4.nabble.com/Subsetting-for-unwanted-values-tp2242506p2242506.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list