[R] Find all numbers in a certain interval

Vitalie Spinu vitosmail at rambler.ru
Wed Dec 17 11:53:39 CET 2008


Hi, 
If you can formulate your question it in terms of actual problem you have with data.frame it would be easier to answer.

for the time being check subset() if it is what you want.

SV.
On Tue, 16 Dec 2008 11:09:19 +0100, Antje <niederlein-rstat at yahoo.de> wrote:

> Hi all,
>
> I'd like to know, if I can solve this with a shorter command:
>
> a <- rnorm(100)
> which(a > -0.5 & a < 0.5)
>
> # would give me all indices of numbers greater than -0.5 and smaller  
> than +0.5
>
> I have something similar with a dataframe and it produces sometimes  
> quite long
> commands...
> I'd like to have something like:
>
> which(within.interval(a, -0.5, 0.5))
>
> Is there anything I could use for this purpose?
>
>
> Antje
>
> ______________________________________________
> 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