[R] Between the values

Gabor Grothendieck ggrothendieck at gmail.com
Tue Aug 12 17:54:55 CEST 2008


SQL has a between operator and via sqldf you can do this using
the built in data frame BOD as an example:

> library(sqldf)
> BOD
  Time demand
1    1    8.3
2    2   10.3
3    3   19.0
4    4   16.0
5    5   15.6
6    7   19.8
> sqldf("select demand between 15 and 17 from BOD")
  demand between 15 and 17
1                        0
2                        0
3                        0
4                        1
5                        1
6                        0
>


On Tue, Aug 12, 2008 at 7:46 AM, Shubha Vishwanath Karanth
<shubhak at ambaresearch.com> wrote:
> Hi R,
>
>
>
> This is a very trivial one....
>
>
>
> C=0.1
>
>
>
> I want to check whether my value of C is between 0 and 1 exclusively....
> I don't want to use (C>0 & C<1). And I can't use a single statement like
> (0<C<1). Is there a between function? Or how do we specify from 0 to 1?
> Does %in% help me?
>
>
>
>
>
> Many Thanks,
>
> Shubha
>
>
>
> This e-mail may contain confidential and/or privileged i...{{dropped:13}}
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list