This function returns the lengh of the longest run of a particular numeric value in a numeric vector. A "run" is an uninterrupted sequence of the same number. Runs can be "wrapped" so that if the sequence starts and ends with the target value then it is considered as a consecutive run.
Examples
x <- c(1, 1, 1, 2, 2, 3, 4, 5, 6, 1, 1, 1, 1, 1)
longRun(x, 2)
#> [1] 2
longRun(x, 1)
#> [1] 5
longRun(x, 1, wrap=TRUE)
#> [1] 8