File: seqToIntervals.Rd

package info (click to toggle)
r-cran-r.utils 2.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,864 kB
  • sloc: sh: 18; makefile: 6
file content (55 lines) | stat: -rw-r--r-- 1,174 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Do not modify this file since it was automatically generated from:
% 
%  seqToIntervals.R
% 
% by the Rdoc compiler part of the R.oo package.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\name{seqToIntervals}
\alias{seqToIntervals.default}
\alias{seqToIntervals}

\title{Gets all contiguous intervals of a vector of indices}

\description{
 Gets all contiguous intervals of a vector of indices.
}

\usage{
\method{seqToIntervals}{default}(idx, ...)
}

\arguments{
  \item{idx}{A \code{\link[base]{vector}} of N \code{\link[base]{integer}} indices.}
  \item{...}{Not used.}
}

\value{
  An Nx2 \code{\link[base]{integer}} \code{\link[base]{matrix}}.
}

\author{Henrik Bengtsson}

\examples{
x <- 1:10
y <- seqToIntervals(x)
print(y)  # [1 10]

x <- c(1:10, 15:18, 20)
y <- seqToIntervals(x)
print(y)  # [1 10; 15 18; 20 20]

z <- intervalsToSeq(y)
print(z)
stopifnot(all.equal(x,z))
}

\seealso{
 
  \code{\link[R.utils:intervalsToSeq.matrix]{*intervalsToSeq}()}.
  To identify sequences of \emph{equal} values, see \code{\link[base]{rle}}().
}


\keyword{attribute}