52_which_functions: Which Functions

Description Usage Arguments Details Value See Also Examples

Description

Sequence based functions, involving indices (or intervals) of minima or maxima.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
which.mins (v, ..., what="I", ends=FALSE)
which.maxs (v, ..., what="I", ends=FALSE)
which.opts (v, ..., what="I", ends=FALSE)

which.level (v, ..., what="intervals")

which.decreasing (v, ..., what="intervals")
which.increasing (v, ..., what="intervals")
which.nondecreasing (v, ..., what="intervals")
which.nonincreasing (v, ..., what="intervals")
which.nonlevel (v, ..., what="intervals")

mins (v, ..., allow.intervals=FALSE, ends=FALSE)
maxs (v, ..., allow.intervals=FALSE, ends=FALSE)
opts (v, ..., allow.intervals=FALSE, ends=FALSE)

Arguments

v

An integer/numeric vector, with length two or more.

allow.intervals

Logical, if true, optimal sections (which two or more equal values) are allowed, if false and there are optimal sections, an error is generated.

what

String, either:
"I" (integer vector of indices)
"intervals" (two-column integer matrix, representing intervals)
"NMP" (integer vector, same as "NMP-")
"NMP-" (integer vector of indices, near mid points, rounds down given even length subintervals)
"NMP+" (integer vector of indices, near mid points, rounds up given even length subintervals)
"XMP" (numeric vector of exact midpoints)
"first" (integer vector of first indices)
"last" (integer vector of last indices)

ends

Logical vector, of length one or two, to include the first/last values as possible optima.

...

Ignored.

Details

These functions are designed to find indices or subintervals matching a pattern.

When what="I", the solutions need to be single indices.
Otherwise, an error is generated.
(Note that "I" is not allowed, for the which.level function).

When what="intervals" the functions return the starting and ending indices of intervals.

For other return types, a single index is returned for each interval.

Value

All "which" functions return an integer vector, which the exception of what="intervals" which returns a two-column integer matrix and what="XMP" which returns a numeric vector.

The mins and maxs functions return values from the original vector.
They may contain duplicated values.

See Also

Unique-Related Functions

Sequence Properties
(Other than unique-related properties).

Other Sequence Functions

Examples

1
2
3
x <- c (2, 1, 0, 1, 2, 1, 0, 1, 2)
which.mins (x)
mins (x)

vectools documentation built on June 7, 2021, 9:08 a.m.