https://github.com/cran/pracma
Raw File
Tip revision: c79a04b5074656b36e591191eb8137b70a349932 authored by Hans W. Borchers on 30 June 2014, 00:00:00 UTC
version 1.7.0
Tip revision: c79a04b
findintervals.Rd
\name{findintervals}
\alias{findintervals}
\title{
  Find Interval Indices
}
\description{
  Find indices \code{i} in vector \code{xs} such that either \code{x=xs[i]}
  or such that \code{xs[i]<x<xs[i+1]} or \code{xs[i]>x>xs[i+1]}.
}
\usage{
findintervals(x, xs)
}
\arguments{
  \item{x}{single number.}
  \item{xs}{numeric vector, not necessarily sorted.}
}
\details{
  Contrary to \code{findInterval}, the vector \code{xs} in
  \code{findintervals} need not be sorted.
}
\value{
  Vector of indices in \code{1..length(xs)}.
  If none is found, returns \code{integer(0)}.
}
\note{
  If \code{x} is equal to the last element in \code{xs}, the index
  \code{length(xs)} will also be returned.
}
\examples{
xs <- zapsmall(sin(seq(0, 10*pi, len=100)))
findintervals(0, xs)
#   1  10  20  30  40  50  60  70  80  90 100
}
\keyword{ logic }

back to top