Learn R Programming

BASIX (version 1.2)

BASIX.find.interval: Positions of elements in a defined region

Description

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

Usage

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

Examples

Run this code
# NOT RUN {
vec  <- c(1,3,5,7,9,10)
from <- 5
to   <- 8
BASIX.find.interval(vec,from,to,1)
# }

Run the code above in your browser using DataLab