https://github.com/cran/pracma
Tip revision: 7e2814c76ec9bc4503af661775ea73f11ec16537 authored by Hans W. Borchers on 15 November 2014, 00:00:00 UTC
version 1.7.9
version 1.7.9
Tip revision: 7e2814c
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 }