Positions of elements in a defined region

Description

This function returns the positions of elements which are in a defined region.

Usage

1
BASIX.find.interval(vec,from,to,start=1)

Arguments

vec

base vector

from

left side

to

right side

start

the start position

Details

The function returns the position of the elements in vector vec,
which are in a specific interval, defined by from and to,
starting from position start.

The native R solution would be:

X <- (vec >= from) & (vec <= to)
ids <- which(X)

or the function findInterval(), which is just a little bit slower than BASIX.interval

Author(s)

Bastian Pfeifer

Examples

1
2
3
4
vec  <- c(1,3,5,7,9,10)
from <- 5
to   <- 8
BASIX.find.interval(vec,from,to,1)