Re: [R] Subsetting for unwanted values

From: Jorge Ivan Velez <jorgeivanvelez_at_gmail.com>
Date: Thu, 03 Jun 2010 20:34:46 -0400

Check ?"%in%

HTH,
Jorge

On Thu, Jun 3, 2010 at 7:52 PM, LCOG1 <> wrote:

>
> 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.
>
> ______________________________________________
> R-help_at_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.
>

        [[alternative HTML version deleted]]



R-help_at_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. Received on Fri 04 Jun 2010 - 00:38:02 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 04 Jun 2010 - 00:50:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive