There is the %<% operator in the TeachingDemos package that allows comparisons like:
5 %<% a %<% 10 But in this case it is not needed (and in this case it takes more key strokes than 5 < a & a < 5, so may not be worth it). -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of bill.venab...@csiro.au > Sent: Monday, February 22, 2010 8:55 PM > To: tu_chun...@yahoo.com; r-help@r-project.org > Subject: Re: [R] Use 2 "ifelse" to sort data > > a <- 1:20 > tt <- ifelse(a > 10, "A", ifelse(a > 5, "B", "C")) > > The problem you have is with '5 < a <= 10'. Such double sided > inequalities are used in mathematics but not in R. Here you only need > the first part, but if you did need both you would need to write > > 5 < a & a <= 10 > > Look carefully and spot the difference. > > Bill Venables > CSIRO/CMIS Cleveland Laboratories > > > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of Chunhao > Sent: Tuesday, 23 February 2010 12:13 PM > To: r-help@r-project.org > Subject: [R] Use 2 "ifelse" to sort data > > > Dear R users, > I have a question how to use 2 "ifelse" to sort my data. Such as > from 11 to 20 assign to A; 6 to 10 assign to B, and the rest of them > assign > to C > > a<-1:20 > > tt<-ifelse(a>10, "A",no=ifelse( 5< a <=10, "B", "C")) > > > Many Thanks > Chunhao > > -- > View this message in context: http://n4.nabble.com/Use-2-ifelse-to- > sort-data-tp1565422p1565422.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. > > ______________________________________________ > 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. ______________________________________________ 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.