R/findFirst.R
findFirst.Rd
This function returns the location of the first, second, third (and so on) occurrence of a specified non-sequential value in a vector.
findFirst(invec, value, event)
invec | The input vector. |
---|---|
value | The value you are looking for. |
event | The desired position to be returned. |
A vector of length 1.
http://stackoverflow.com/q/22049035/1270695
Ananda Mahto
#> [1] "A" "D" "A" "B" "E" "C" "B" "C" "C" "A" "E" "E" "B" "B" "A" "E" "E" "A" "A" #> [20] "E"## Note the difference between the following. ## The value "2" is skipped because it is sequential. which(a == "B")#> [1] 4 7 13 14findFirst(a, "B", 2)#> [1] 7