View source: R/sl.match.comp.R
sl.match.comp | R Documentation |
A simple function returning the index i
of the first element of a vector table
for which table[i] COMP x == TRUE
, where x
is a scalar and COMP
is one of a number of comparison operators that can be specified.
sl.match.comp(x, table, comp.op = "gt", offset = 0)
x |
a scalar to be compared with the elements of |
table |
a vector whose elements are to be compared with |
comp.op |
a character giving a comparison operator. Must be one of 'gt' ('greater than'; default), 'lt' (less than), 'get' (greater than or equal with), 'let' (less than or equal with), and 'eq' (equal with). |
offset |
an integer indicating how many indices to skip at the beginning. |
Note that the function works with matrices, too, but in an unexpected manner, returning a one-dimensional index.
An integer giving the index of the first element (optionally after skipping a number of elements) for which the comparison is TRUE
.
Helge Goessling
sl.match.comp(x=7.2,table=seq(1,10),comp.op="gt")
## Should return:
## [1] 8
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.