Hi R community I have a little problem, and I tried to solve it by myself but I couldn't. I building an if loop, and I want to check a value inside an interval. This would be the case: pvalue=0,2999 if(pvalue>0.05 or pvalue<0.1) as you can see I would like to check in that if loop if my pvalue is inside of that interval(from 0.05 to 0.1), and I tried these options: if(pvalue>0.05 or pvalue<0.1) (not possible because R don't recognise OR as operator) if(pvalue>0.05 || pvalue<0.1) (this one is not good enough, cause it fulfills one condition pvalue>0.05 but it doesn't get other contidion pvalue<0.1) does anyone know a way to stablish a inteval as an statement for my if loop. Thanks in advance Lucas _________________________________________________________________ [[alternative HTML version deleted]]
Hi Lucas, try: if(pvalue>0.05 & pvalue<0.1) HTH Marcio Lucas Sevilla Garc?a wrote:> > > Hi R community > > I have a little problem, and I tried to solve it by myself but I couldn't. > I building an if loop, and I want to check a value inside an interval. > This would be the case: > > pvalue=0,2999 > > if(pvalue>0.05 or pvalue<0.1) > > as you can see I would like to check in that if loop if my pvalue is > inside of that interval(from 0.05 to 0.1), and I tried these options: > > if(pvalue>0.05 or pvalue<0.1) (not possible because R don't recognise OR > as operator) > > if(pvalue>0.05 || pvalue<0.1) (this one is not good enough, cause it > fulfills one condition pvalue>0.05 but it doesn't get other contidion > pvalue<0.1) > > does anyone know a way to stablish a inteval as an statement for my if > loop. > > Thanks in advance > > Lucas > > _________________________________________________________________ > > > [[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. > >-- View this message in context: http://www.nabble.com/Check-value-interval-in-a-if-loop-tp25635562p25635651.html Sent from the R help mailing list archive at Nabble.com.
Lucas Sevilla Garc?a wrote:> Hi R community > > I have a little problem, and I tried to solve it by myself but I couldn't. I building an if loop, and I want to check a value inside an interval. This would be the case: > > pvalue=0,2999 > > if(pvalue>0.05 or pvalue<0.1) > > as you can see I would like to check in that if loop if my pvalue is inside of that interval(from 0.05 to 0.1), and I tried these options: > > if(pvalue>0.05 or pvalue<0.1) (not possible because R don't recognise OR as operator) > > if(pvalue>0.05 || pvalue<0.1) (this one is not good enough, cause it fulfills one condition pvalue>0.05 but it doesn't get other contidion pvalue<0.1) > > does anyone know a way to stablish a inteval as an statement for my if loop.1. if() is not used for constructing loops (and I think you know that) 2. You need an "and" operator rather than "or", such as & (for vectors) or && (for scalar values). Uwe Ligges> Thanks in advance > > Lucas > > _________________________________________________________________ > > > [[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.