Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

which.first

Find the index of first/last TRUE value in a logical vector.


Description

Find the index of first/last TRUE value in a logical vector.

Usage

which.first(x, use.names = TRUE)

which.last(x, use.names = TRUE)

Arguments

x

[logical]
Logical vector.

use.names

[logical(1)]
If TRUE and x is named, the result is also named.

Value

[integer(1) | integer(0)]. Returns the index of the first/last TRUE value in x or an empty integer vector if none is found.

Examples

which.first(c(FALSE, TRUE))
 which.last(c(FALSE, FALSE))

BBmisc

Miscellaneous Helper Functions for B. Bischl

v1.11
BSD_2_clause + file LICENSE
Authors
Bernd Bischl [aut, cre], Michel Lang [aut], Jakob Bossek [aut], Daniel Horn [aut], Jakob Richter [aut], Dirk Surmann [aut]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.