Hi,

Here is one way:

> is.there <- function(mynumber, a, b)  mynumber %in% a:b
> is.there(4, 1, 10)
[1] TRUE
> is.there(459124, 103000, 983000)
[1] TRUE
> is.there(4, 103000, 983000)
[1] FALSE

HTH,
Jorge


On Thu, Aug 12, 2010 at 7:10 PM, fishkbob <> wrote:

>
> So basically I want to do this -
>
> 4 %in% 1:10
> should return true
>
> Would there be another way of doing this without having to do the 1:10
> part?
>
> I am using a very large data set and trying to do
>
> 459124 %in% 103000:983000
>
> multiple times for many values, and it is taking quite a long time
>
> Also, I would like to vary the x:y part, so I can't even make an object
> that
> is c(x:y) and do a which(#=c(x:y)) because I would need to change x and y
> each time.
> --
> View this message in context:
> http://r.789695.n4.nabble.com/find-value-between-two-other-numbers-tp2323513p2323513.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.
>

        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to