From: Thomas Lumley > > On Mon, 26 Mar 2007, Marc Schwartz wrote: > > > Sergio, > > > > Please be sure to cc: the list (ie. Reply to All) with follow up > > questions. > > > > In this case, you would use %in% with a negation: > > > > NewDF <- subset(DF, (var1 == 0) & (var2 == 0) & (!var3 %in% 2:3)) > > > > Probably a typo: should be !(var3 %in% 2:3) rather than (!var > %in% 2:3)
I used to think so, but found I didn't need the parens: R> a <- 1:3; b <- c(1, 3, 5) R> ! a %in% b [1] FALSE TRUE FALSE R> ! (a %in% b) [1] FALSE TRUE FALSE Andy > -thomas > > > See ?"%in%" for more information. > > > > HTH, > > > > Marc > > > > On Mon, 2007-03-26 at 17:30 +0200, Sergio Della Franca wrote: > >> Ok, this run correctly. > >> > >> Another question for you: > >> > >> I want to put more than one condition for var3, i.e.: > >> I like to create a subset when: > >> - var1=0 > >> - var2=0 > >> - var3 is different from 2 and from 3. > >> > >> Like you suggested, i perform this code: > >> NewDF <- subset(DF, (var1 == 0) & (var2 == 0) & (var 3 != > 2)) & (var > >> 3 != 3)) > >> > >> There is a method to combine (var 3 != 2)) & (var 3 != 3)) in one > >> condition? > >> > >> Thank you. > >> > >> Sergio > >> > >> > >> > >> 2007/3/26, Marc Schwartz <[EMAIL PROTECTED]>: > >> On Mon, 2007-03-26 at 17:02 +0200, Sergio Della > Franca wrote: > >> > Dear R-Helpers, > >> > > >> > I want to make a subset from my data set. > >> > > >> > I'd like to perform different condition for subset. > >> > > >> > I.e.: > >> > > >> > I like to create a subset when: > >> > - var1=0 > >> > - var2=0 > >> > - var3 is different from 2. > >> > > >> > How can i develop a subset under this condition? > >> > > >> > Thank you in advance. > >> > > >> > Sergio Della Franca. > >> > >> See ?subset > >> > >> Something along the lines of the following should work: > >> > >> NewDF <- subset(DF, (var1 == 0) & (var2 == 0) & > (var 3 != 0)) > >> > >> HTH, > >> > >> Marc Schwartz > > > > ______________________________________________ > > R-help@stat.math.ethz.ch 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. > > > > Thomas Lumley Assoc. Professor, Biostatistics > [EMAIL PROTECTED] University of Washington, Seattle > > ______________________________________________ > R-help@stat.math.ethz.ch 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. > > > ------------------------------------------------------------------------------ Notice: This e-mail message, together with any attachments,...{{dropped}} ______________________________________________ R-help@stat.math.ethz.ch 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.