I definitely used too much lines s of code because I still don't know how to
do some staff.
but it works:
seq=5         #starting value
var=5        # starting value
long= 1:10   # length of the vector
for (x in long){
        var=var+((var/100)*40)
    seq=append(seq,var)
}
seq=round(seq)
seq=cumsum(seq)
> seq
 [1]    5   17   39   75  130  212  332  505  752 1102 1597


Probably I could set just a variable instead of 2 ( var and seq)
and set the value of long directly to 10, but as I said I just started using
R


Thanks :)

?cumsum
> cumsum(yoursequence)
>
> HTH,
> Jorge
>
>
> On Mon, 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
>>
>> I can generate the first sequence but I don t know how to generate the
>> last.
>>
>> I would really appreciate your help.
>> Thanks
>> HVZ
>>
>>        [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to