I want to find a list of previous max. So for a vector: 3, 2,2,3,4,3,9,5,2,3,4,6,120,1 The first max is 3, the second max is 4 (because, 4>3), then 9(because 9>4) and then 120 (120>9) So, as an output I would need the position: 1,5,7,13
Is there anyway to do this without a for loop?
```
vector<-c(3, 2,2,3,4,3,9,5,2,3,4,6,120,1)
results<-1
max<-3
for(i in 2:length(vector)){
if(vector[i]>max{
results<-c(results, i)
max<-vector[i]}
else {next}
}
```