findFirst: Find the First, Second, n Non-sequential Position of a Value...

Description Usage Arguments Value Author(s) References Examples

View source: R/findFirst.R

Description

This function returns the location of the first, second, third (and so on) occurrence of a specified non-sequential value in a vector.

Usage

1
findFirst(invec, value, event)

Arguments

invec

The input vector.

value

The value you are looking for.

event

The desired position to be returned.

Value

A vector of length 1.

Author(s)

Ananda Mahto

References

http://stackoverflow.com/q/22049035/1270695

Examples

1
2
3
4
5
6
7
8
9
set.seed(1)
a <- sample(LETTERS[1:5], 20, TRUE)
a

## Note the difference between the following.
## The value "2" is skipped because it is sequential.
which(a == "B")

findFirst(a, "B", 2)

mrdwab/SOfun documentation built on June 20, 2020, 6:15 p.m.