I would like to find the largest element in a portion of a longer vector. I would also like to perform this calculation for multiple \'pieces\' of this larger vector. The f
This should do the job
cummax(test.vec)
Besides sum, min, max, prod, for which a more efficient routine is built-in, the general strategy might be
Reduce(max, test.vec, accumulate = TRUE)
You might be interested in the cummax function.
cummax