Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sequence increasing by percentage

Tags:

r

Is it possible to create a seq in R with increasing values by percentage?

For example:

In need a sequence of values from 10500 to approximately 30000 increasing by 1 %

So the first value after 10500 have to be 10605, the next one 10711.5 .....

Is this possible in R with the command seq? Ore maybe with another Function?

Something like:

seq(10500,30000,1%)
like image 808
Hark Avatar asked Feb 24 '17 11:02

Hark


1 Answers

cumprod is your friend:

cumprod(c(10500, rep(1.01,50)))

produces

 [1] 10500.00 10605.00 10711.05 10818.16 10926.34 11035.61 11145.96 11257.42 11370.00 11483.70
like image 81
rbm Avatar answered Nov 13 '22 10:11

rbm