Re: [R] vector decreasing by a factor

From: Ted Harding <>
Date: Mon, 02 May 2011 09:50:59 +0100 (BST)

On 02-May-11 07:55:27, andre bedon wrote:
> Hi,
> I'm quite new to R so this question will sound quite fundamental.
> I need to create a vector of length 160. The first element should
> be (1+r)^159 and each element thereafter should decrease by a
> factor of (1+r) until the 160th element that should be 1.
> Is there a function similar to seq() but increasing or decreasing
> by factors? I need to do this in one step i.e, not using loops.
> Any help would be greatly appreciated.
> Regards,
> Andre

One expression which would do what you want is


though there may be more efficient ways to do it. This assumes that r, hence (1+r), is given. If you are given the value X1 of the first element, which is to be interpreted as (1+r)^159, then perhaps take (1+r) as X1^(1/159), though there is a potential slight inaccuracy in recovering X0 from (1+r)^159. So check this first.

Hoping this helps,

E-Mail: (Ted Harding) <> Fax-to-email: +44 (0)870 094 0861
Date: 02-May-11                                       Time: 09:50:55
------------------------------ XFMail ------------------------------

______________________________________________ mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Thu 05 May 2011 - 06:25:07 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 05 May 2011 - 07:00:06 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive