I have a vector of positive numbers such that - if the number is greater or equal to 1, it gets added - if the number is less than 1, it multiplies the cumulative sum.
For example
> set.seed(0)
> x <- sample(c(0.9, 0.9, 0.9, 1:3), 10, replace=T)
> x
[1] 3.0 0.9 0.9 1.0 3.0 0.9 3.0 3.0 1.0 1.0
The resulting vector
3 2.7 2.43 3.43 6.43 5.787 8.787 11.787 12.787 13.787
Is there a way to do it without using a for loop?