Re: [R] Subsetting for unwanted values

From: Joris Meys <jorismeys_at_gmail.com>
Date: Fri, 04 Jun 2010 02:11:06 +0200

> PcToAdd_<-Pc[!(Pc %in% Pc.X)]
> PcToAdd_
[1] "Res" "Os" "Gov" "Rur"
> PcToAdd_<-subset(Pc,!(Pc %in% Pc.X))
> PcToAdd_

[1] "Res" "Os" "Gov" "Rur"
>

On Fri, Jun 4, 2010 at 1:52 AM, LCOG1 <jroll_at_lcog.org> 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.
>

-- 
Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
Joris.Meys_at_Ugent.be
-------------------------------
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

______________________________________________
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:14:08 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:20:30 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