[R] find value between two other numbers?
baptiste auguie
baptiste.auguie at googlemail.com
Fri Aug 13 08:27:40 CEST 2010
Hi,
I see no need to construct the vector, try this instead,
belong = function(x=4, y=c(1,10)) x <= y[2] && x >= y[1]
see also ?findInterval
HTH,
baptiste
On 13 August 2010 01:10, fishkbob <fishkbob at gmail.com> 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 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