Function to find if a value is greater than all prior values in a vector
You can use cummax()
to get the biggest value so far. x >= cummax(x)
basically gives you the answer, although element 1 is TRUE
, so you just need to change that:
> out = x >= cummax(x)
> out[1] = NA
> out
[1] NA TRUE FALSE TRUE FALSE