[R] Number in interval
Greg.Snow at imail.org
Mon Jul 18 22:39:07 CEST 2011
A small modification of this would be:
> -3 %<=% z %<=% 3
Whether that is prettier or uglier than Jim's answer is in the eye of the beholder (for longer variable names this version could save a few key strokes).
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
greg.snow at imail.org
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of jim holtman
> Sent: Sunday, July 17, 2011 3:29 PM
> To: Manuel K.
> Cc: r-help at r-project.org
> Subject: Re: [R] Number in interval
> try this:
> > z <- c(-1.4,0.5,4.7)
> > (z >= -3) & (z <= 3)
>  TRUE TRUE FALSE
> On Sun, Jul 17, 2011 at 10:54 AM, Manuel K. <b8220126 at klzlk.com> wrote:
> > Hi all,
> > I have an interval (e.g [-3,3]) and a numeric vector z (-
> 1.4,0.5,4.7). How
> > can I test whether an element in z lies between between -3,3? I
> > need a TRUE/FALSE response.
> > Thanks
> > Manuel
> > --
> > View this message in context: http://r.789695.n4.nabble.com/Number-
> > 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-
> > and provide commented, minimal, self-contained, reproducible code.
> Jim Holtman
> Data Munger Guru
> What is the problem that you are trying to solve?
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help