[R] Sequence

David Winsemius dwinsemius at comcast.net
Tue Aug 23 03:50:47 CEST 2011


On Aug 22, 2011, at 8:36 PM, Claudio Zanettini wrote:

> Hello everyone,
> I would like to generate a sequence
> such as, starting from 5, every value  is
> 40% of the value before+ all the preceeding values.
> es:
> this is the seq of all the value+40% of the preceding value:
> 5         7        10        14        19        27        38
> 53        74       103       145       202       283       397
> 556       778      1089      1525      2134      2988      4183
>
> then the vector tha I need is
> 5 , 5+7, 5+7+10, 5+7+10+14 and so on

If you have the first vector, then the second vector is just:

cumsum(vec)

(I am not sure this actually implements the problem statement. I would  
have imagined the third item to be 12+0.4*7 from the written  
description and for it to increase more rapidly.)

>
> I can generate the first sequence but I don t know how to generate  
> the last.

You should offer code when you have a partial solution.

-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list